From 9b5364a3afb03414bd6e3ded2fbfdacabe4e8870 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Wed, 11 Jan 2017 17:06:31 +0100 Subject: daemon: Allow check builds of 'builtin:download' derivations. Fixes . Reported by Leo Famulari . * nix/libstore/build.cc (DerivationGoal::runChild): In the 'isBuiltin' case, check whether DRV's output is in 'redirectedOutputs', and pass an 'output' argument to the built-in builder. (DerivationGoal::addHashRewrite): Add 'printMsg' call. * nix/libstore/builtins.hh (derivationBuilder): Add 'output' parameter. * nix/libstore/builtins.cc (builtinDownload): Likewise. Add OUTPUT to ARGV. * guix/scripts/perform-download.scm (perform-download): Add 'output' parameter. (guix-perform-download): Adjust 'match' clauses accordingly. * tests/derivations.scm ("'download' built-in builder, check mode"): New test. --- nix/libstore/build.cc | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'nix/libstore/build.cc') diff --git a/nix/libstore/build.cc b/nix/libstore/build.cc index 38048ceebc..cebc404d1c 100644 --- a/nix/libstore/build.cc +++ b/nix/libstore/build.cc @@ -2271,8 +2271,17 @@ void DerivationGoal::runChild() logType = ltFlat; auto buildDrv = lookupBuiltinBuilder(drv.builder); - if (buildDrv != NULL) - buildDrv(drv, drvPath); + if (buildDrv != NULL) { + /* Check what the output file name is. When doing a + 'bmCheck' build, the output file name is different from + that specified in DRV due to hash rewriting. */ + Path output = drv.outputs["out"].path; + auto redirected = redirectedOutputs.find(output); + if (redirected != redirectedOutputs.end()) + output = redirected->second; + + buildDrv(drv, drvPath, output); + } else throw Error(format("unsupported builtin function '%1%'") % string(drv.builder, 8)); _exit(0); @@ -2742,6 +2751,8 @@ Path DerivationGoal::addHashRewrite(const Path & path) rewritesToTmp[h1] = h2; rewritesFromTmp[h2] = h1; redirectedOutputs[path] = p; + printMsg(lvlChatty, format("output '%1%' redirected to '%2%'") + % path % p); return p; } -- cgit 1.4.1