aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr
diff options
context:
space:
mode:
Diffstat (limited to 'src/libexpr')
-rw-r--r--src/libexpr/primops.cc8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc
index 6a4b5b042..f555de73e 100644
--- a/src/libexpr/primops.cc
+++ b/src/libexpr/primops.cc
@@ -872,8 +872,12 @@ static void prim_toFile(EvalState & state, const Pos & pos, Value * * args, Valu
for (auto path : context) {
if (path.at(0) == '=') path = string(path, 1);
- if (isDerivation(path))
- throw EvalError(format("in ‘toFile’: the file ‘%1%’ cannot refer to derivation outputs, at %2%") % name % pos);
+ if (isDerivation(path)) {
+ /* See prim_unsafeDiscardOutputDependency. */
+ if (path.at(0) != '~')
+ throw EvalError(format("in ‘toFile’: the file ‘%1%’ cannot refer to derivation outputs, at %2%") % name % pos);
+ path = string(path, 1);
+ }
refs.insert(path);
}