aboutsummaryrefslogtreecommitdiffstats
path: root/tests/fixtures.sh
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-12 02:15:26 +0000
committertv <tv@krebsco.de>2026-11-12 02:15:26 +0000
commitd4c352a402aec1682625144c0440ca31c232ee74 (patch)
tree898da22caf12a75227fe517c6f7330ffa840b032 /tests/fixtures.sh
parent1c7621261c4e9df8d572aef5eb6369d20eea23aa (diff)
tests: add edge cases of flakes
A new test, edge-cases, covers paths that work but have no scenario yet: a flake given by an indirect reference, which the target fetches by its locked reference; a remote flake in a subdirectory; a flake in a subdirectory drawing inputs from sources; a dirty Git work tree; a flake whose lock file needs updating; drawing inputs from a source that isn't a directory; nested names of missing inputs; several sources sharing one flake; and an input locked to a path that the target has. The deploying machine gets a registry entry for the indirect reference. Resolving it fails if the global registry can't be downloaded, which it can't in the VM, and disabling the global registry with flake-registry needs flakes, so the deploying machine enables them, like any deploying machine using indirect references does. The target doesn't, so checks for flake support on targets still mean something.
Diffstat (limited to 'tests/fixtures.sh')
-rwxr-xr-xtests/fixtures.sh39
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/fixtures.sh b/tests/fixtures.sh
index eb62a61..9608fcd 100755
--- a/tests/fixtures.sh
+++ b/tests/fixtures.sh
@@ -108,6 +108,45 @@ NIX
(cd /fixtures/usegone && nix flake lock)
rm -R /fixtures/gone
+# kropsremote: a registry entry for remote, so it has an indirect reference.
+nix registry add kropsremote "$url/remote.tar.gz"
+
+# monoin: a Git work tree with a flake in subdirectory sub that has an input.
+mkdir -p /fixtures/monoin/sub
+echo monoin > /fixtures/monoin/README
+cat > /fixtures/monoin/sub/flake.nix <<NIX
+{
+ inputs.dep.url = "$url/dep.tar.gz";
+ outputs = { dep, ... }: { msg = "monoin:\${dep.greeting}"; };
+}
+NIX
+(cd /fixtures/monoin/sub && nix flake lock)
+(cd /fixtures/monoin && git init -q && commit monoin)
+
+# dirty: a copy of top with an uncommitted change and an untracked file.
+cp -R /fixtures/top /fixtures/dirty
+sed -i 's/top:/dirty:/' /fixtures/dirty/flake.nix
+echo untracked > /fixtures/dirty/untracked
+
+# unlocked: a flake whose lock file is missing.
+mkdir /fixtures/unlocked
+cat > /fixtures/unlocked/flake.nix <<NIX
+{
+ inputs.inner.url = "$url/inner.tar.gz";
+ outputs = { inner, ... }: { msg = inner.who; };
+}
+NIX
+
+# uselocal: a flake with an input locked to a path on the deploying machine.
+mkdir /fixtures/uselocal
+cat > /fixtures/uselocal/flake.nix <<'NIX'
+{
+ inputs.a.url = "path:/fixtures/alt";
+ outputs = { a, ... }: { msg = "uselocal:${a.who}"; };
+}
+NIX
+(cd /fixtures/uselocal && nix flake lock)
+
# noflake: a directory without flake.nix.
mkdir /fixtures/noflake
echo noflake > /fixtures/noflake/README