Skip to content

Commit 762273f

Browse files
committed
Allow empty hash in derivations
follow up of #3544 This allows hash="" so that it can be used for debugging purposes. For instance, this gives you an error message like: warning: found empty hash, assuming you wanted 'sha256:0000000000000000000000000000000000000000000000000000' hash mismatch in fixed-output derivation '/nix/store/asx6qw1r1xk6iak6y6jph4n58h4hdmbm-nix': wanted: sha256:0000000000000000000000000000000000000000000000000000 got: sha256:0fpfhipl9v1mfzw2ffmxiyyzqwlkvww22bh9wcy4qrfslb4jm429
1 parent d558fb9 commit 762273f

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/libexpr/primops.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,13 @@ static void prim_derivationStrict(EvalState & state, const Pos & pos, Value * *
719719
throw Error(format("multiple outputs are not supported in fixed-output derivations, at %1%") % posDrvName);
720720

721721
HashType ht = outputHashAlgo.empty() ? htUnknown : parseHashType(outputHashAlgo);
722-
Hash h(*outputHash, ht);
722+
723+
Hash h;
724+
if (outputHash->empty()) {
725+
h = Hash(ht);
726+
printError("warning: found empty hash, assuming you wanted '%s'", h.to_string());
727+
} else
728+
h = Hash(*outputHash, ht);
723729

724730
auto outPath = state.store->makeFixedOutputPath(ingestionMethod, h, drvName);
725731
if (!jsonObject) drv.env["out"] = state.store->printStorePath(outPath);

0 commit comments

Comments
 (0)