aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2019-04-16 12:22:28 +0200
committerEelco Dolstra <edolstra@gmail.com>2019-04-16 12:22:28 +0200
commitdd935404b2cdb4f15991f6ff651d41415e66fd69 (patch)
tree6e5acb84ab4055c217e0e4bc1bbf0362092ccb6a
parentb4e367bf4a28b5495bc349df6fff0694ae73b9c2 (diff)
parent7587d62d02f216f28034f9e0938eb3236494c41b (diff)
Merge remote-tracking branch 'tweag/flakePinIssues' into flakes
-rw-r--r--src/libexpr/primops/flake.hh2
-rw-r--r--src/nix/flake.cc17
2 files changed, 17 insertions, 2 deletions
diff --git a/src/libexpr/primops/flake.hh b/src/libexpr/primops/flake.hh
index 8bfceb756..80114c7c8 100644
--- a/src/libexpr/primops/flake.hh
+++ b/src/libexpr/primops/flake.hh
@@ -63,6 +63,8 @@ struct NonFlake
NonFlake(const FlakeRef flakeRef) : ref(flakeRef) {};
};
+std::shared_ptr<FlakeRegistry> getGlobalRegistry();
+
Flake getFlake(EvalState &, const FlakeRef &, bool impureIsAllowed);
struct Dependencies
diff --git a/src/nix/flake.cc b/src/nix/flake.cc
index dbf0d3e9a..8634733d6 100644
--- a/src/nix/flake.cc
+++ b/src/nix/flake.cc
@@ -129,6 +129,8 @@ struct CmdFlakeInfo : FlakeCommand, MixJSON, MixEvalArgs, StoreCommand
return "list info about a given flake";
}
+ CmdFlakeInfo () { evalSettings.pureEval = false; }
+
void run(nix::ref<nix::Store> store) override
{
auto evalState = std::make_shared<EvalState>(searchPath, store);
@@ -156,6 +158,7 @@ struct CmdFlakeAdd : MixEvalArgs, Command
{
expectArg("alias", &alias);
expectArg("flake-uri", &uri);
+ evalSettings.pureEval = false;
}
void run() override
@@ -186,6 +189,7 @@ struct CmdFlakeRemove : virtual Args, MixEvalArgs, Command
CmdFlakeRemove()
{
expectArg("alias", &alias);
+ evalSettings.pureEval = false;
}
void run() override
@@ -214,6 +218,7 @@ struct CmdFlakePin : virtual Args, StoreCommand, MixEvalArgs
CmdFlakePin()
{
expectArg("alias", &alias);
+ evalSettings.pureEval = false;
}
void run(nix::ref<nix::Store> store) override
@@ -227,8 +232,16 @@ struct CmdFlakePin : virtual Args, StoreCommand, MixEvalArgs
it->second = getFlake(*evalState, it->second, true).ref;
// The 'ref' in 'flake' is immutable.
writeRegistry(userRegistry, userRegistryPath);
- } else
- throw Error("the flake alias '%s' does not exist in the user registry", alias);
+ } else {
+ std::shared_ptr<FlakeRegistry> globalReg = getGlobalRegistry();
+ it = globalReg->entries.find(FlakeRef(alias));
+ if (it != globalReg->entries.end()) {
+ FlakeRef newRef = getFlake(*evalState, it->second, true).ref;
+ userRegistry.entries.insert_or_assign(alias, newRef);
+ writeRegistry(userRegistry, userRegistryPath);
+ } else
+ throw Error("the flake alias '%s' does not exist in the user or global registry", alias);
+ }
}
};