From 1ed55234d9efce7d40c97ef1215090015d18498c Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Thu, 23 Jul 2015 09:34:06 -0400 Subject: Allow derivations-as-srcs in the context of builtins.toFile files --- src/libexpr/primops.cc | 8 ++++++-- 1 file 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); } -- cgit v1.2.3