diff options
-rw-r--r-- | corepkgs/fetchurl/fetchurl.fix | 1 | ||||
-rw-r--r-- | corepkgs/fetchurl/fetchurl.sh | 8 | ||||
-rw-r--r-- | src/fix.cc | 17 | ||||
-rw-r--r-- | src/fstate.cc | 5 | ||||
-rw-r--r-- | src/fstate.hh | 2 | ||||
-rw-r--r-- | src/normalise.cc | 7 |
6 files changed, 23 insertions, 17 deletions
diff --git a/corepkgs/fetchurl/fetchurl.fix b/corepkgs/fetchurl/fetchurl.fix index f798c0bec..0221b612c 100644 --- a/corepkgs/fetchurl/fetchurl.fix +++ b/corepkgs/fetchurl/fetchurl.fix @@ -4,6 +4,7 @@ Function(["url", "md5"], , ("url", Var("url")) , ("md5", Var("md5")) , ("name", BaseName(Var("url"))) + , ("id", Var("md5")) ] ) ) diff --git a/corepkgs/fetchurl/fetchurl.sh b/corepkgs/fetchurl/fetchurl.sh index 1479e898b..7b6243974 100644 --- a/corepkgs/fetchurl/fetchurl.sh +++ b/corepkgs/fetchurl/fetchurl.sh @@ -4,9 +4,7 @@ echo "downloading $url into $out..." wget "$url" -O "$out" || exit 1 actual=$(md5sum -b $out | cut -c1-32) -if ! test "$md5" == "ignore"; then - if ! test "$actual" == "$md5"; then - echo "hash is $actual, expected $md5" - exit 1 - fi +if ! test "$actual" == "$md5"; then + echo "hash is $actual, expected $md5" + exit 1 fi diff --git a/src/fix.cc b/src/fix.cc index 6e3809f82..93cc27cfc 100644 --- a/src/fix.cc +++ b/src/fix.cc @@ -153,8 +153,10 @@ static Expr evalExpr2(EvalState & state, Expr e) fs.slice.roots.push_back(id); fs.slice.elems.push_back(elem); - return ATmake("FSId(<str>)", - ((string) writeTerm(unparseFState(fs), "")).c_str()); + FSId termId = hashString("producer-" + (string) id + + "-" + dstPath); + writeTerm(unparseFState(fs), "", termId); + return ATmake("FSId(<str>)", ((string) termId).c_str()); } /* Packages are transformed into Derive fstate expressions. */ @@ -176,6 +178,7 @@ static Expr evalExpr2(EvalState & state, Expr e) fs.type = FState::fsDerive; fs.derive.platform = SYSTEM; string name; + FSId outId; bnds = ATempty; for (map<string, ATerm>::iterator it = bndMap.begin(); @@ -195,6 +198,7 @@ static Expr evalExpr2(EvalState & state, Expr e) } else if (ATmatch(value, "<str>", &s1)) { if (key == "name") name = s1; + if (key == "id") outId = parseHash(s1); fs.derive.env.push_back(StringPair(key, s1)); } else throw badTerm("invalid package argument", value); @@ -211,7 +215,8 @@ static Expr evalExpr2(EvalState & state, Expr e) /* Hash the fstate-expression with no outputs to produce a unique but deterministic path name for this package. */ - Hash outId = hashTerm(unparseFState(fs)); + if (outId == FSId()) + outId = hashTerm(unparseFState(fs)); string outPath = canonPath(nixStore + "/" + ((string) outId).c_str() + "-" + name); fs.derive.env.push_back(StringPair("out", outPath)); @@ -219,8 +224,10 @@ static Expr evalExpr2(EvalState & state, Expr e) debug(format("%1%: %2%") % (string) outId % name); /* Write the resulting term into the Nix store directory. */ - return ATmake("FSId(<str>)", - ((string) writeTerm(unparseFState(fs), "-d-" + name)).c_str()); + FSId termId = hashString("producer-" + (string) outId + + "-" + outPath); + writeTerm(unparseFState(fs), "-d-" + name, termId); + return ATmake("FSId(<str>)", ((string) termId).c_str()); } /* BaseName primitive function. */ diff --git a/src/fstate.cc b/src/fstate.cc index 85f8c75cc..1c8c6776f 100644 --- a/src/fstate.cc +++ b/src/fstate.cc @@ -31,9 +31,10 @@ ATerm termFromId(const FSId & id) } -FSId writeTerm(ATerm t, const string & suffix) +FSId writeTerm(ATerm t, const string & suffix, FSId id) { - FSId id = hashTerm(t); + /* By default, the id of a term is its hash. */ + if (id == FSId()) id = hashTerm(t); string path = canonPath(nixStore + "/" + (string) id + suffix + ".nix"); diff --git a/src/fstate.hh b/src/fstate.hh index 681a8d094..969abe9e0 100644 --- a/src/fstate.hh +++ b/src/fstate.hh @@ -63,7 +63,7 @@ Hash hashTerm(ATerm t); ATerm termFromId(const FSId & id); /* Write an aterm to the Nix store directory, and return its hash. */ -FSId writeTerm(ATerm t, const string & suffix); +FSId writeTerm(ATerm t, const string & suffix, FSId id = FSId()); /* Parse an fstate-expression. */ FState parseFState(ATerm t); diff --git a/src/normalise.cc b/src/normalise.cc index fcb9c4d0d..d06c8bf36 100644 --- a/src/normalise.cc +++ b/src/normalise.cc @@ -88,19 +88,18 @@ Slice normaliseFState(FSId id) /* We can skip running the builder if we can expand all output paths from their ids. */ - bool fastBuild = false; -#if 0 + bool fastBuild = true; for (OutPaths::iterator i = outPaths.begin(); i != outPaths.end(); i++) { try { expandId(i->second, i->first); - } catch (...) { + } catch (Error & e) { + debug(format("fast build failed: %1%") % e.what()); fastBuild = false; break; } } -#endif if (!fastBuild) { |