aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShea Levy <shea@shealevy.com>2015-07-23 09:34:06 -0400
committerEelco Dolstra <eelco.dolstra@logicblox.com>2015-07-23 17:03:47 +0200
commit1ed55234d9efce7d40c97ef1215090015d18498c (patch)
tree23ebb9e5716a68f3437ad4e41cb852d217dd3040
parent61af14a9219bff090b238f15c9def5453087aa5d (diff)
Allow derivations-as-srcs in the context of builtins.toFile files
-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);
}