diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2005-01-14T13·51+0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2005-01-14T13·51+0000 |
commit | 9530cc31700f68fd229eee69eabd2baa099f404a (patch) | |
tree | 5cc317adeb0c8098d8a9197a0bcbcb29ee4d941d /src/libexpr | |
parent | a7b94e87d7d28f763a708876cba46c8f2484b526 (diff) |
* Start move towards SHA-256 hashes instead of MD5.
* Start cleaning up unique store path generation (they weren't always unique; in particular the suffix ("-aterm-2.2", "-builder.sh") was not part of the hash, therefore changes to the suffix would cause multiple store objects with the same hash).
Diffstat (limited to 'src/libexpr')
-rw-r--r-- | src/libexpr/primops.cc | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc index f73e60e387bd..59b85a6d6233 100644 --- a/src/libexpr/primops.cc +++ b/src/libexpr/primops.cc @@ -59,7 +59,7 @@ static Path copyAtom(EvalState & state, const Path & srcPath) ne.closure.elems[dstPath] = elem; Hash drvHash = hashDerivation(state, ne); - Path drvPath = writeTerm(unparseStoreExpr(ne), ""); + Path drvPath = writeTerm(unparseStoreExpr(ne), "c"); state.drvHashes.insert(make_pair(drvPath, drvHash)); state.drvRoots[drvPath] = ne.closure.roots; @@ -250,21 +250,32 @@ static Expr primDerivation(EvalState & state, const ATermVector & _args) throw Error(format("invalid character `%1%' in derivation name `%2%'") % *i % drvName); } + + /* Construct the "masked" derivation store expression, which is + the final one except that the list of output paths is set to + the set of output names, and the corresponding environment + variables have an empty value. This ensures that changes in + the set of output names do get reflected in the hash. */ + ne.derivation.env["out"] = ""; + ne.derivation.outputs.insert("out"); /* Determine the output path by hashing the Nix expression with no outputs to produce a unique but deterministic path name for this derivation. */ if (!outHashGiven) outHash = hashDerivation(state, ne); - Path outPath = canonPath(nixStore + "/" + - ((string) outHash).c_str() + "-" + drvName); + Path outPath = makeStorePath("output:out", + outHash, drvName); + + /* Construct the final derivation store expression. */ ne.derivation.env["out"] = outPath; + ne.derivation.outputs.clear(); ne.derivation.outputs.insert(outPath); /* Write the resulting term into the Nix store directory. */ Hash drvHash = outHashGiven ? hashString((string) outHash + outPath, htMD5) : hashDerivation(state, ne); - Path drvPath = writeTerm(unparseStoreExpr(ne), "-d-" + drvName); + Path drvPath = writeTerm(unparseStoreExpr(ne), "d-" + drvName); printMsg(lvlChatty, format("instantiated `%1%' -> `%2%'") % drvName % drvPath); |