aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Van den Broeck <nick.van.den.broeck666@gmail.com>2019-06-11 13:09:06 +0200
committerNick Van den Broeck <nick.van.den.broeck666@gmail.com>2019-06-18 17:01:57 +0200
commit59714a15e0b36c93a7c19b71344a9fccf7b9840d (patch)
treed9b54cf2de00f3204277f634f975114da7f0e7bd
parentc4d740115e391335361eaf9706b75f303a4b8002 (diff)
FuzzyMatching works
Fixes #2843
-rw-r--r--src/libexpr/flake/flake.cc1
-rw-r--r--tests/flakes.sh56
2 files changed, 56 insertions, 1 deletions
diff --git a/src/libexpr/flake/flake.cc b/src/libexpr/flake/flake.cc
index 0018a0d07..30ab9a876 100644
--- a/src/libexpr/flake/flake.cc
+++ b/src/libexpr/flake/flake.cc
@@ -104,6 +104,7 @@ static FlakeRef lookupFlake(EvalState & state, const FlakeRef & flakeRef, const
auto newRef = j->second;
newRef.ref = flakeRef.ref;
newRef.rev = flakeRef.rev;
+ newRef.subdir = flakeRef.subdir;
return updateFlakeRef(state, newRef, registries, pastSearches);
}
}
diff --git a/tests/flakes.sh b/tests/flakes.sh
index c380b405b..85ba7c8c9 100644
--- a/tests/flakes.sh
+++ b/tests/flakes.sh
@@ -15,6 +15,7 @@ registry=$TEST_ROOT/registry.json
flake1Dir=$TEST_ROOT/flake1
flake2Dir=$TEST_ROOT/flake2
flake3Dir=$TEST_ROOT/flake3
+flake4Dir=$TEST_ROOT/flake4
nonFlakeDir=$TEST_ROOT/nonFlake
for repo in $flake1Dir $flake2Dir $flake3Dir $nonFlakeDir; do
@@ -101,6 +102,12 @@ cat > $registry <<EOF
"flake3": {
"uri": "file://$flake3Dir"
},
+ "file://$flake4Dir": {
+ "uri": "file://$flake3Dir"
+ },
+ "flake4": {
+ "uri": "flake3"
+ },
"nixpkgs": {
"uri": "flake1"
}
@@ -110,7 +117,7 @@ cat > $registry <<EOF
EOF
# Test 'nix flake list'.
-(( $(nix flake list --flake-registry $registry | wc -l) == 4 ))
+(( $(nix flake list --flake-registry $registry | wc -l) == 6 ))
# Test 'nix flake info'.
nix flake info --flake-registry $registry flake1 | grep -q 'ID: *flake1'
@@ -274,3 +281,50 @@ nix build -o $TEST_ROOT/result --flake-registry $registry flake3:sth
mv $flake2Dir.tmp $flake2Dir
mv $nonFlakeDir.tmp $nonFlakeDir
nix build -o $TEST_ROOT/result --flake-registry $registry flake3:xyzzy flake3:fnord
+
+# Test doing multiple `lookupFlake`s
+nix build -o $TEST_ROOT/result --flake-registry $registry flake4:xyzzy
+nix build -o $TEST_ROOT/result --flake-registry $registry file://$flake4Dir:xyzzy
+
+# Make branch "removeXyzzy" where flake3 doesn't have xyzzy anymore
+git -C $flake3Dir checkout -b removeXyzzy
+rm $flake3Dir/flake.nix
+
+cat > $flake3Dir/flake.nix <<EOF
+{
+ name = "flake3";
+
+ epoch = 201906;
+
+ inputs = [ "flake1" "flake2" ];
+
+ nonFlakeInputs = {
+ nonFlake = "$nonFlakeDir";
+ };
+
+ description = "Fnord";
+
+ outputs = inputs: rec {
+ packages.sth = inputs.flake1.packages.foo;
+ packages.fnord =
+ with import ./config.nix;
+ mkDerivation {
+ inherit system;
+ name = "fnord";
+ buildCommand = ''
+ cat \${inputs.nonFlake}/README.md > \$out
+ '';
+ };
+ };
+}
+EOF
+git -C $flake3Dir add flake.nix
+git -C $flake3Dir commit -m 'Remove packages.xyzzy'
+git -C $flake3Dir checkout master
+
+# Test whether fuzzy-matching works for IsAlias
+(! nix build -o $TEST_ROOT/result --flake-registry $registry flake4/removeXyzzy:xyzzy)
+
+# Test whether fuzzy-matching works for IsGit
+(! nix build -o $TEST_ROOT/result --flake-registry $registry flake4/removeXyzzy:xyzzy)
+nix build -o $TEST_ROOT/result --flake-registry $registry flake4/removeXyzzy:sth