From 28972864879a63c4110211d9852b692672869a2a Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 18 Mar 2009 17:36:42 +0000 Subject: * Unify exportReferencesGraph and exportBuildReferencesGraph, and make sure that it works as expected when you pass it a derivation. That is, we have to make sure that all build-time dependencies are built, and that they are all in the input closure (otherwise remote builds might fail, for example). This is ensured at instantiation time by adding all derivations and their sources to inputDrvs and inputSrcs. --- src/libexpr/primops.cc | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) (limited to 'src/libexpr/primops.cc') diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc index 717f649c4e04..34e7e80525c5 100644 --- a/src/libexpr/primops.cc +++ b/src/libexpr/primops.cc @@ -399,16 +399,29 @@ static Expr prim_derivationStrict(EvalState & state, const ATermVector & args) /* Everything in the context of the strings in the derivation attributes should be added as dependencies of the resulting derivation. */ - for (PathSet::iterator i = context.begin(); i != context.end(); ++i) { + foreach (PathSet::iterator, i, context) { Path path = *i; - bool buildDrv = true; + + /* Paths marked with `=' denote that the path of a derivation + is explicitly passed to the builder. Since that allows the + builder to gain access to every path in the dependency + graph of the derivation (including all outputs), all paths + in the graph must be added to this derivation's list of + inputs to ensure that they are available when the builder + runs. */ if (path.at(0) == '=') { - buildDrv = false; path = string(path, 1); + PathSet refs; computeFSClosure(path, refs); + foreach (PathSet::iterator, j, refs) { + drv.inputSrcs.insert(*j); + if (isDerivation(*j)) + drv.inputDrvs[*j] = singleton("out"); + } } + debug(format("derivation uses `%1%'") % path); assert(isStorePath(path)); - if (buildDrv && isDerivation(path)) + if (isDerivation(path)) drv.inputDrvs[path] = singleton("out"); else drv.inputSrcs.insert(path); @@ -484,7 +497,7 @@ static Expr prim_derivationStrict(EvalState & state, const ATermVector & args) outAttrs.set(toATerm("outPath"), makeAttrRHS(makeStr(outPath, singleton(drvPath)), makeNoPos())); outAttrs.set(toATerm("drvPath"), - makeAttrRHS(makeStr(drvPath, singleton(drvPath)), makeNoPos())); + makeAttrRHS(makeStr(drvPath, singleton("=" + drvPath)), makeNoPos())); return makeAttrs(outAttrs); } @@ -541,13 +554,6 @@ static Expr prim_storePath(EvalState & state, const ATermVector & args) Path path2 = toStorePath(path); if (!store->isValidPath(path2)) throw EvalError(format("store path `%1%' is not valid") % path2); - /* If this is a derivation, mark it so it doesn't get built; - i.e. we want the dependency as a "source" dependency. This is - to make nix-push work properly (we want it to create a NAR - archive of the derivation, not build the derivation as a - side-effect). The `=' is a special marker that gets stripped - off by prim_derivationStrict. */ - if (isDerivation(path2)) path2 = "=" + path2; context.insert(path2); return makeStr(path, context); } -- cgit 1.4.1