Factor out EvalCache::forceDerivation()
This commit is contained in:
parent
ca946860ce
commit
b681408879
|
@ -2,6 +2,7 @@
|
||||||
#include "sqlite.hh"
|
#include "sqlite.hh"
|
||||||
#include "eval.hh"
|
#include "eval.hh"
|
||||||
#include "eval-inline.hh"
|
#include "eval-inline.hh"
|
||||||
|
#include "store-api.hh"
|
||||||
|
|
||||||
namespace nix::eval_cache {
|
namespace nix::eval_cache {
|
||||||
|
|
||||||
|
@ -502,4 +503,19 @@ bool AttrCursor::isDerivation()
|
||||||
return aType && aType->getString() == "derivation";
|
return aType && aType->getString() == "derivation";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StorePath AttrCursor::forceDerivation()
|
||||||
|
{
|
||||||
|
auto aDrvPath = getAttr(root->state.sDrvPath);
|
||||||
|
auto drvPath = root->state.store->parseStorePath(aDrvPath->getString());
|
||||||
|
if (!root->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();
|
||||||
|
if (!root->state.store->isValidPath(drvPath))
|
||||||
|
throw Error("don't know how to recreate store derivation '%s'!",
|
||||||
|
root->state.store->printStorePath(drvPath));
|
||||||
|
}
|
||||||
|
return drvPath;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,6 +101,9 @@ public:
|
||||||
bool isDerivation();
|
bool isDerivation();
|
||||||
|
|
||||||
Value & forceValue();
|
Value & forceValue();
|
||||||
|
|
||||||
|
/* Force creation of the .drv file in the Nix store. */
|
||||||
|
StorePath forceDerivation();
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -444,17 +444,7 @@ std::tuple<std::string, FlakeRef, InstallableValue::DerivationInfo> InstallableF
|
||||||
if (!attr->isDerivation())
|
if (!attr->isDerivation())
|
||||||
throw Error("flake output attribute '%s' is not a derivation", attrPath);
|
throw Error("flake output attribute '%s' is not a derivation", attrPath);
|
||||||
|
|
||||||
auto aDrvPath = attr->getAttr(state->sDrvPath);
|
auto drvPath = attr->forceDerivation();
|
||||||
auto drvPath = state->store->parseStorePath(aDrvPath->getString());
|
|
||||||
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();
|
|
||||||
if (!state->store->isValidPath(drvPath))
|
|
||||||
throw Error("don't know how to recreate store derivation '%s'!",
|
|
||||||
state->store->printStorePath(drvPath));
|
|
||||||
}
|
|
||||||
|
|
||||||
auto drvInfo = DerivationInfo{
|
auto drvInfo = DerivationInfo{
|
||||||
std::move(drvPath),
|
std::move(drvPath),
|
||||||
|
|
Loading…
Reference in a new issue