aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2020-04-03 13:07:05 +0200
committerEelco Dolstra <edolstra@gmail.com>2020-04-03 13:07:05 +0200
commit9c78f7f196454228e378d19e4686526214e61bc7 (patch)
treefee29baa71bddadac13a75c0d14465a0b587e581 /src/libexpr
parentbb39f2bb8a835696986ac01416a73fe11cb0b0ba (diff)
getFlake: In pure mode, check that the argument is an immutable flakeref
Diffstat (limited to 'src/libexpr')
-rw-r--r--src/libexpr/flake/flake.cc7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/libexpr/flake/flake.cc b/src/libexpr/flake/flake.cc
index 59362c018..313f3bdbd 100644
--- a/src/libexpr/flake/flake.cc
+++ b/src/libexpr/flake/flake.cc
@@ -628,8 +628,13 @@ void callFlake(EvalState & state,
static void prim_getFlake(EvalState & state, const Pos & pos, Value * * args, Value & v)
{
+ auto flakeRefS = state.forceStringNoCtx(*args[0], pos);
+ auto flakeRef = parseFlakeRef(flakeRefS);
+ if (evalSettings.pureEval && !flakeRef.input->isImmutable())
+ throw Error("cannot call 'getFlake' on mutable flake reference '%s', at %s (use --impure to override)", flakeRefS, pos);
+
callFlake(state,
- lockFlake(state, parseFlakeRef(state.forceStringNoCtx(*args[0], pos)),
+ lockFlake(state, flakeRef,
LockFlags {
.updateLockFile = false,
.useRegistries = !evalSettings.pureEval,