diff options
| author | tv <tv@krebsco.de> | 2026-11-14 02:07:45 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-14 02:07:45 +0000 |
| commit | 06f3ddfd3a32e9038ea36c6e196d71adf1753391 (patch) | |
| tree | 61440a9feb5f80bc54c12842b5b5eb2526feaf62 /pkgs/populate/tests | |
| parent | 7dfacd6437fe361b59d142901cd8343266c50bd8 (diff) | |
populate: check each Git work tree once per run
git_problems looks through all of a work tree for .git files and
directories, which takes long for big ones like nixpkgs. A git source
drawn from by a flake-input source got checked three times per run:
when delivering it, by resolve, deciding on git+file:, and by
derived_state, for the key. populate notes the work trees git_problems
found nothing wrong with during the run, and resolve and derived_state
get told, so git_flake only checks the rest, e.g. hooks.
The git source's script prints checked if it checked the work tree that
was there, instead of making a fresh clone. Its commands print to
standard error, without getting the standard output populate reads, so
nothing they leave running keeps populate waiting.
rewrite-cache-gitsource is rewrite-cache-git with a git source.
Diffstat (limited to 'pkgs/populate/tests')
| -rw-r--r-- | pkgs/populate/tests/scenarios.nix | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/pkgs/populate/tests/scenarios.nix b/pkgs/populate/tests/scenarios.nix index 35645d4..5622782 100644 --- a/pkgs/populate/tests/scenarios.nix +++ b/pkgs/populate/tests/scenarios.nix @@ -738,6 +738,58 @@ with import ./builder.nix args; } ]; })) + # Like rewrite-cache-git, with a git source, which populate checks + # once per run, when delivering it, and the flakes step doesn't check + # again. + (s "rewrite-cache-gitsource" (let + sources = { + x.flake-input = { + url = "/fixtures/top"; name = "dep"; inherit fetchOnTarget; + inputs.inner.follows = "g"; + }; + g.git = { url = "git://deployer/rewrite-cache-gitsource.git"; ref = "master"; }; + }; + commit = who: '' + cd /tmp/rewrite-cache-gitsource + echo '{ outputs = _: { who = "${who}"; }; }' > flake.nix + git add flake.nix + git -c user.name=krops -c user.email=spam@krebsco.de commit -q -m ${who} + git push -q -f /fixtures/git/rewrite-cache-gitsource.git master + ''; + in { + prepareDeployer = '' + rm -fR /tmp/rewrite-cache-gitsource /fixtures/git/rewrite-cache-gitsource.git + git init -q --bare /fixtures/git/rewrite-cache-gitsource.git + git init -q -b master /tmp/rewrite-cache-gitsource + '' + commit "gitsource"; + phases = [ + { + inherit sources; + check = checkFlake { attr = "greeting"; expected = "dep+gitsource"; } + '' + grep -q '"type": "git"' "$T"/x/flake.lock || + fail "g isn't referred to as git+file:" + ''; + mutate = '' + readlink "$T"/x > "$T".first + stat -c %y "$T"/.populate/derived/x/key > "$T".key + ''; + } + { + inherit sources; + check = '' + expect_eq "store path" "$(readlink "$T"/x)" "$(cat "$T".first)" + expect_eq "copy made at" "$(stat -c %y "$T"/.populate/derived/x/key)" "$(cat "$T".key)" + ''; + mutateDeployer = commit "gitsource2"; + } + { + inherit sources; + check = checkFlake { attr = "greeting"; expected = "dep+gitsource2"; } + '' + test "$(readlink "$T"/x)" != "$(cat "$T".first)" || fail "store path unchanged" + ''; + } + ]; + })) # A materialized input is a writable copy, patched and with a rewritten # lock file, which gets made again only when what it derives from # changes, and becomes a link again when not materialized anymore. |
