1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-25 14:51:16 +02:00

fetchTree: Don't crash if narHash is missing

Fixes

  nix: ../src/libexpr/primops/fetchTree.cc:37: void nix::emitTreeAttrs(EvalState&, const StorePath&, const fetchers::Input&, Value&, bool, bool): Assertion `narHash' failed.

on a lock file with an input that doesn't have a narHash. This can
happen when using a lock file created by the lazy-trees branch.

Cherry-picked from lazy-trees.
This commit is contained in:
Eelco Dolstra 2024-11-21 16:53:34 +01:00
parent 45b0158d91
commit f4f4b698f6

View file

@ -33,9 +33,8 @@ void emitTreeAttrs(
// FIXME: support arbitrary input attributes.
auto narHash = input.getNarHash();
assert(narHash);
attrs.alloc("narHash").mkString(narHash->to_string(HashFormat::SRI, true));
if (auto narHash = input.getNarHash())
attrs.alloc("narHash").mkString(narHash->to_string(HashFormat::SRI, true));
if (input.getType() == "git")
attrs.alloc("submodules").mkBool(