Evaluation cache: Don't barf in read-only mode

Fixes

  $ nix copy
  warning: Git tree '/home/eelco/Dev/nix-flake' is dirty
  nix: src/nix/installables.cc:348: std::tuple<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, nix::FlakeRef, nix::InstallableValue::DerivationInfo> nix::InstallableFlake::toDerivation(): Assertion `state->store->isValidPath(drvPath)' failed.
  Aborted (core dumped)
This commit is contained in:
Eelco Dolstra 2020-04-29 15:42:53 +02:00
parent 5ada0831cf
commit 70bcd6a55c

View file

@ -339,12 +339,14 @@ std::tuple<std::string, FlakeRef, InstallableValue::DerivationInfo> InstallableF
auto aDrvPath = attr->getAttr(state->sDrvPath);
auto drvPath = state->store->parseStorePath(aDrvPath->getString());
if (!state->store->isValidPath(drvPath)) {
if (!state->store->isValidPath(drvPath) && !settings.readOnlyMode) {
/* The eval cache contains 'drvPath', but the actual path
has been garbage-collected. So force it to be
regenerated. */
aDrvPath->forceValue();
assert(state->store->isValidPath(drvPath));
if (!state->store->isValidPath(drvPath))
throw Error("don't know how to recreate store derivation '%s'!",
state->store->printStorePath(drvPath));
}
auto drvInfo = DerivationInfo{