From 7837a236e728988fcd501917444828b790c367f9 Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 20 Nov 2026 01:48:55 +0000 Subject: populate: lock files rewritten in place change only if they differ A file or git source whose lock file the flakes step rewrites in place gets the original back from delivering it, on every run, from rsync, or from git reset, which also printed HEAD is now at, and Nix printed that it updates the lock file, so the record said the source changed on every run. Populate keeps a copy of the rewritten lock file in .populate/locks/, and the flakes step compares with it, printing what Nix says about the lock file, and changed, only if it differs. Delivering such a source doesn't count bringing back the lock file: rsync returns the paths of what it changed, and the git source's script takes the lock file's path, and resets quietly if that's all that differs. relock also checks that the second, unchanged, run prints nothing about lock files, and says nothing changed, now for rewriting in place too. --- pkgs/populate/tests/scenarios.nix | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'pkgs/populate/tests') diff --git a/pkgs/populate/tests/scenarios.nix b/pkgs/populate/tests/scenarios.nix index a5ac6ea..fbcae73 100644 --- a/pkgs/populate/tests/scenarios.nix +++ b/pkgs/populate/tests/scenarios.nix @@ -546,11 +546,13 @@ in }; })) # The lock file gets rewritten or generated again when a source inputs - # get drawn from changes. What Nix prints about a generated flake's lock - # file only gets printed then. + # get drawn from changes. What Nix prints about the lock file only gets + # printed then, and the record only says x changed then, also when + # delivering x brings back the lock file that gets rewritten in place. (modes "relock" ({ draw, flake, mode, ... }: let x.file = { path = "/fixtures/filesrc"; } // draw { dep.follows = "a"; }; - generated = optional (mode == "generated"); + # Nix updates the lock file of x, or creates it, if x has none. + message = if mode == "generated" then "creating lock file" else "lock file"; in { phases = [ { @@ -558,20 +560,22 @@ in check = '' expect_eq msg "$(nix_eval_online ${flake "x"}#msg)" top:alt,sub ''; - output = generated "creating lock file"; + output = [ message ]; } { sources = { inherit x; a.file = "/fixtures/alt"; }; check = '' expect_eq msg "$(nix_eval_online ${flake "x"}#msg)" top:alt,sub + expect_eq changed "$(record changed)" false ''; - unexpected = generated "lock file"; + unexpected = [ "lock file" ]; } { - output = generated "creating lock file"; + output = [ message ]; sources = { inherit x; a.file = "/fixtures/alt2"; }; check = '' expect_eq msg "$(nix_eval_online ${flake "x"}#msg)" top:alt2,sub + expect_eq "x changed" "$(record sources.x.changed)" true ''; } ]; -- cgit v1.3.1