diff options
| author | tv <tv@krebsco.de> | 2026-11-14 02:50:05 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-14 03:59:29 +0100 |
| commit | feda621a3a6b29c55c179059259d938d83e30f6e (patch) | |
| tree | c14d03ef84c834571a5897024cf47e538c83f0dc /pkgs/populate/tests | |
| parent | 4ed0731ecab446ed0cc4a6146df414a36978e05b (diff) | |
populate: print what Nix says about lock files only if something changed
Looking at a flake with inputs drawn from sources, populate overrides
those inputs with an empty flake, which makes Nix warn that it doesn't
write the lock file it changed, listing the overrides, on every run,
locally for archiving a flake or flake-input source, and on the target
for checking the inputs drawn. nix_looking leaves that warning out of
what Nix prints.
A generated flake gets locked anew on every run, so it pins what the
inputs are now, which made Nix print that it creates the lock file,
listing all inputs, on every run. That only gets printed if the lock
file differs from the one there was.
No phase is expected to print Nix's warning, and relock's second phase,
which changes nothing, isn't expected to print anything about the
generated flake's lock file.
Diffstat (limited to 'pkgs/populate/tests')
| -rw-r--r-- | pkgs/populate/tests/builder.nix | 5 | ||||
| -rw-r--r-- | pkgs/populate/tests/scenarios.nix | 15 |
2 files changed, 17 insertions, 3 deletions
diff --git a/pkgs/populate/tests/builder.nix b/pkgs/populate/tests/builder.nix index 26a360b..91609a9 100644 --- a/pkgs/populate/tests/builder.nix +++ b/pkgs/populate/tests/builder.nix @@ -143,7 +143,10 @@ let null else { populate = toString (command sources targetPath); - inherit env interrupt output unexpected; + inherit env interrupt output; + # Nix warns about not writing lock files whenever populate looks + # at a flake, which populate leaves out. + unexpected = unexpected ++ [ "not writing modified lock file" ]; expect = if expect' == "success" then null else expect'.fail; status = if expect' == "success" then null else expect'.status or null; # No phase gets around checking the canaries. diff --git a/pkgs/populate/tests/scenarios.nix b/pkgs/populate/tests/scenarios.nix index 5622782..2ab2d0e 100644 --- a/pkgs/populate/tests/scenarios.nix +++ b/pkgs/populate/tests/scenarios.nix @@ -534,9 +534,11 @@ with import ./builder.nix args; }; })) # The lock file gets rewritten or generated again when a source inputs - # get drawn from changes. - (modes "relock" ({ draw, flake, ... }: let + # get drawn from changes. What Nix prints about a generated flake's lock + # file only gets printed then. + (modes "relock" ({ draw, flake, mode, ... }: let x.file = { path = "/fixtures/filesrc"; } // draw { dep.follows = "a"; }; + generated = optional (mode == "generated"); in { phases = [ { @@ -544,8 +546,17 @@ with import ./builder.nix args; check = '' expect_eq msg "$(nix_eval_online ${flake "x"}#msg)" top:alt,sub ''; + output = generated "creating lock file"; } { + sources = { inherit x; a.file = "/fixtures/alt"; }; + check = '' + expect_eq msg "$(nix_eval_online ${flake "x"}#msg)" top:alt,sub + ''; + unexpected = generated "lock file"; + } + { + output = generated "creating lock file"; sources = { inherit x; a.file = "/fixtures/alt2"; }; check = '' expect_eq msg "$(nix_eval_online ${flake "x"}#msg)" top:alt2,sub |
