Fix handling of bare flakerefs containing a colon

This commit is contained in:
Eelco Dolstra 2019-05-31 22:17:39 +02:00
parent 8abb8647a3
commit 8cb3bbd504
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE
2 changed files with 7 additions and 4 deletions

View file

@ -314,6 +314,10 @@ std::vector<std::shared_ptr<Installable>> SourceExprCommand::parseInstallables(
Strings{"packages." + std::string(s, 8)})); Strings{"packages." + std::string(s, 8)}));
} }
else if (auto flakeRef = parseFlakeRef(s, true))
result.push_back(std::make_shared<InstallableFlake>(*this, s,
getDefaultFlakeAttrPaths()));
else if ((colon = s.rfind(':')) != std::string::npos) { else if ((colon = s.rfind(':')) != std::string::npos) {
auto flakeRef = std::string(s, 0, colon); auto flakeRef = std::string(s, 0, colon);
auto attrPath = std::string(s, colon + 1); auto attrPath = std::string(s, colon + 1);
@ -332,10 +336,6 @@ std::vector<std::shared_ptr<Installable>> SourceExprCommand::parseInstallables(
getDefaultFlakeAttrPaths())); getDefaultFlakeAttrPaths()));
} }
else if (auto flakeRef = parseFlakeRef(s, true))
result.push_back(std::make_shared<InstallableFlake>(*this, s,
getDefaultFlakeAttrPaths()));
else else
result.push_back(std::make_shared<InstallableFlake>(*this, FlakeRef("nixpkgs"), s)); result.push_back(std::make_shared<InstallableFlake>(*this, FlakeRef("nixpkgs"), s));
} }

View file

@ -134,6 +134,9 @@ nix build -o $TEST_ROOT/result --flake-registry $registry flake1:foo
nix build -o $TEST_ROOT/result --flake-registry $registry flake1 nix build -o $TEST_ROOT/result --flake-registry $registry flake1
[[ -e $TEST_ROOT/result/hello ]] [[ -e $TEST_ROOT/result/hello ]]
nix build -o $TEST_ROOT/result --flake-registry $registry $flake1Dir
nix build -o $TEST_ROOT/result --flake-registry $registry file://$flake1Dir
# Building a flake with an unlocked dependency should fail in pure mode. # Building a flake with an unlocked dependency should fail in pure mode.
(! nix eval "(builtins.getFlake "$flake2Dir")") (! nix eval "(builtins.getFlake "$flake2Dir")")