diff options
| author | tv <tv@krebsco.de> | 2026-11-13 20:28:00 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-13 21:59:13 +0100 |
| commit | 24fd14b1e6de45def6a59b65486f5035ac486ee3 (patch) | |
| tree | ff9928227578c3befa83bfcdee41548aa978efe8 /tests | |
| parent | b34f53d538c5afa95fd0dc6dd81b56e4995b80c2 (diff) | |
populate: refer to flakes as git+file: only with a usable .git
Writing the lock file of a git+file: flake, Nix runs Git, with the
repository's configuration and hooks, which may run commands. A .git
in a source's directory can come from anywhere, e.g. one planted in a
materialized flake, or one a file source keeps. So drawing inputs
refers to a flake as git+file: only if git_problems finds nothing wrong
with its .git directory, the way git sources check their work trees,
and else as path:.
lock-foreign-git plants a .git in a materialized flake and in a file
source that keeps it, whose configuration names an fsmonitor command.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/scenarios.nix | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/scenarios.nix b/tests/scenarios.nix index d12dcd1..15d0a53 100644 --- a/tests/scenarios.nix +++ b/tests/scenarios.nix @@ -2188,6 +2188,51 @@ assert !(krops.isLocalTarget (targets.remote "/")); } ]; })) + # A .git that a materialized flake got, and one that a file source + # keeps, which Nix uses for the git+file: URL of the flake there: writing + # its lock file, Nix runs Git, with that repository's configuration. + (s "lock-foreign-git" (let + elsewhere = "/var/krops-elsewhere"; + sources = alt // { + x.flake-input = { + url = "/fixtures/top"; name = "dep"; inherit fetchOnTarget; + materialize = true; + inputs.inner.follows = "alt"; + }; + y.file = { + path = "/fixtures/filesrc"; + deleteExcluded = false; + filters = [ { type = "exclude"; pattern = "/.git"; } ]; + inputs.dep.follows = "alt"; + }; + }; + in { + isolate = true; + prepare = '' + rm -fR ${elsewhere} + mkdir -p ${elsewhere} + ''; + phases = [ + { + inherit sources; + # Repositories tracking only flake.nix, so the lock file changes. + mutate = '' + for name in x y; do + git -C "$T"/$name init -q + git -C "$T"/$name add flake.nix + git -C "$T"/$name -c user.name=x -c user.email=x@x commit -q -m x + git -C "$T"/$name config core.fsmonitor "touch ${elsewhere}/ran; false" + done + ''; + } + { + inherit sources; + check = '' + test ! -e ${elsewhere}/ran || fail "a command in a .git directory ran" + ''; + } + ]; + })) # A file in populate's state replaced by a symlink to a file outside. (s "state-key" (let sources.x.flake-input = { |
