diff --git a/src/libcmd/installables.cc b/src/libcmd/installables.cc index 1c414e9e2..080557d4f 100644 --- a/src/libcmd/installables.cc +++ b/src/libcmd/installables.cc @@ -491,7 +491,11 @@ Installables SourceExprCommand::parseInstallables( throw UsageError("'--file' and '--expr' are exclusive"); // FIXME: backward compatibility hack - if (file) evalSettings.pureEval = false; + if (file) { + if (evalSettings.pureEval && evalSettings.pureEval.overridden) + throw UsageError("'--file' is not compatible with '--pure-eval'"); + evalSettings.pureEval = false; + } auto state = getEvalState(); auto vFile = state->allocValue(); diff --git a/tests/functional/eval.sh b/tests/functional/eval.sh index ed9c214f5..f876f5ac4 100755 --- a/tests/functional/eval.sh +++ b/tests/functional/eval.sh @@ -39,6 +39,9 @@ nix-instantiate --eval -E 'assert 1 + 2 == 3; true' ln -sfn cycle.nix "$TEST_ROOT/cycle.nix" (! nix eval --file "$TEST_ROOT/cycle.nix") +# --file and --pure-eval don't mix. +expectStderr 1 nix eval --pure-eval --file "$TEST_ROOT/cycle.nix" | grepQuiet "not compatible" + # Check that relative symlinks are resolved correctly. mkdir -p "$TEST_ROOT/xyzzy" "$TEST_ROOT/foo" ln -sfn ../xyzzy "$TEST_ROOT/foo/bar"