aboutsummaryrefslogtreecommitdiff
path: root/tests/functional
diff options
context:
space:
mode:
authorMaximilian Bosch <maximilian@mbosch.me>2024-05-03 16:43:28 +0200
committerjade <lix@jade.fyi>2024-05-03 22:54:38 +0000
commit0e38720502c10ddba4afb8c49532b69be83e23a7 (patch)
tree2f722f48e2ccae57b40d286f7a6f4e7bdc38cb38 /tests/functional
parentf8617f9dc65096ee1e83fe3d100cc252e9f94bf6 (diff)
Revert "Revert "Merge pull request #6621 from Kha/nested-follows""
This reverts commit a8b3d777fbdaf0b732f129e5be62cd2a1227674b. This undoes the revert of PR#6621, which allows nested `follows`, i.e. { inputs = { foo.url = "github:bar/foo"; foo.inputs.bar.inputs.nixpkgs = "nixpkgs"; }; } does the expected thing now. This is useful to avoid the 1000 instances of nixpkgs problem without having each flake in the dependency tree to expose all of its transitive dependencies for modification. This was in fact part of Nix before and the C++ changes applied w/o conflicts. However, it got reverted then because people didn't want to merge lazy-trees against it which was supposed to be merged soon back in October 2022. Fixes: https://git.lix.systems/lix-project/lix/issues/201 Change-Id: I5ddef914135b695717b2ef88862d57ced5e7aa3c
Diffstat (limited to 'tests/functional')
-rw-r--r--tests/functional/flakes/follow-paths.sh60
1 files changed, 60 insertions, 0 deletions
diff --git a/tests/functional/flakes/follow-paths.sh b/tests/functional/flakes/follow-paths.sh
index 183893bde..cd3f75693 100644
--- a/tests/functional/flakes/follow-paths.sh
+++ b/tests/functional/flakes/follow-paths.sh
@@ -230,3 +230,63 @@ git -C "$flakeFollowsOverloadA" add flake.nix flakeB/flake.nix \
nix flake metadata "$flakeFollowsOverloadA"
nix flake update --flake "$flakeFollowsOverloadA"
nix flake lock "$flakeFollowsOverloadA"
+
+# Test nested flake overrides: A overrides B/C/D
+
+cat <<EOF > $flakeFollowsD/flake.nix
+{ outputs = _: {}; }
+EOF
+cat <<EOF > $flakeFollowsC/flake.nix
+{
+ inputs.D.url = "path:nosuchflake";
+ outputs = _: {};
+}
+EOF
+cat <<EOF > $flakeFollowsB/flake.nix
+{
+ inputs.C.url = "path:$flakeFollowsC";
+ outputs = _: {};
+}
+EOF
+cat <<EOF > $flakeFollowsA/flake.nix
+{
+ inputs.B.url = "path:$flakeFollowsB";
+ inputs.D.url = "path:$flakeFollowsD";
+ inputs.B.inputs.C.inputs.D.follows = "D";
+ outputs = _: {};
+}
+EOF
+
+nix flake lock $flakeFollowsA
+
+[[ $(jq -c .nodes.C.inputs.D $flakeFollowsA/flake.lock) = '["D"]' ]]
+
+# Test overlapping flake follows: B has D follow C/D, while A has B/C follow C
+
+cat <<EOF > $flakeFollowsC/flake.nix
+{
+ inputs.D.url = "path:$flakeFollowsD";
+ outputs = _: {};
+}
+EOF
+cat <<EOF > $flakeFollowsB/flake.nix
+{
+ inputs.C.url = "path:nosuchflake";
+ inputs.D.url = "path:nosuchflake";
+ inputs.D.follows = "C/D";
+ outputs = _: {};
+}
+EOF
+cat <<EOF > $flakeFollowsA/flake.nix
+{
+ inputs.B.url = "path:$flakeFollowsB";
+ inputs.C.url = "path:$flakeFollowsC";
+ inputs.B.inputs.C.follows = "C";
+ outputs = _: {};
+}
+EOF
+
+# bug was not triggered without recreating the lockfile
+nix flake update --flake $flakeFollowsA
+
+[[ $(jq -c .nodes.B.inputs.D $flakeFollowsA/flake.lock) = '["B","C","D"]' ]]