libexpr: associate stores and repair flag with EvalContext
Change-Id: I5fd911415707f0b250888dcabdf6290691fcdbf3
This commit is contained in:
parent
d30027a37a
commit
5db5eed43d
|
@ -223,8 +223,8 @@ static std::strong_ordering comparePriorities(EvalState & state, DrvInfo & drv1,
|
|||
static bool isPrebuilt(EvalState & state, DrvInfo & elem)
|
||||
{
|
||||
auto path = elem.queryOutPath(state);
|
||||
if (state.store->isValidPath(path)) return true;
|
||||
return state.store->querySubstitutablePaths({path}).count(path);
|
||||
if (state.ctx.store->isValidPath(path)) return true;
|
||||
return state.ctx.store->querySubstitutablePaths({path}).count(path);
|
||||
}
|
||||
|
||||
|
||||
|
@ -432,7 +432,7 @@ static void queryInstSources(EvalState & state,
|
|||
case srcStorePaths: {
|
||||
|
||||
for (auto & i : args) {
|
||||
auto path = state.store->followLinksToStorePath(i);
|
||||
auto path = state.ctx.store->followLinksToStorePath(i);
|
||||
|
||||
std::string name(path.name());
|
||||
|
||||
|
@ -441,7 +441,7 @@ static void queryInstSources(EvalState & state,
|
|||
|
||||
if (path.isDerivation()) {
|
||||
elem.setDrvPath(path);
|
||||
auto outputs = state.store->queryDerivationOutputMap(path);
|
||||
auto outputs = state.ctx.store->queryDerivationOutputMap(path);
|
||||
elem.setOutPath(outputs.at("out"));
|
||||
if (name.size() >= drvExtension.size() &&
|
||||
std::string(name, name.size() - drvExtension.size()) == drvExtension)
|
||||
|
@ -496,7 +496,7 @@ static void printMissing(EvalState & state, DrvInfos & elems)
|
|||
.path = i.queryOutPath(state),
|
||||
});
|
||||
|
||||
printMissing(state.store, targets);
|
||||
printMissing(state.ctx.store, targets);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ void processExpr(EvalState & state, const Strings & attrPaths,
|
|||
getDerivations(state, v, "", autoArgs, drvs, false);
|
||||
for (auto & i : drvs) {
|
||||
auto drvPath = i.requireDrvPath(state);
|
||||
auto drvPathS = state.store->printStorePath(drvPath);
|
||||
auto drvPathS = state.ctx.store->printStorePath(drvPath);
|
||||
|
||||
/* What output do we want? */
|
||||
std::string outputName = i.queryOutputName(state);
|
||||
|
@ -78,7 +78,7 @@ void processExpr(EvalState & state, const Strings & attrPaths,
|
|||
else {
|
||||
Path rootName = absPath(gcRoot);
|
||||
if (++rootNr > 1) rootName += "-" + std::to_string(rootNr);
|
||||
auto store2 = state.store.dynamic_pointer_cast<LocalFSStore>();
|
||||
auto store2 = state.ctx.store.dynamic_pointer_cast<LocalFSStore>();
|
||||
if (store2)
|
||||
drvPathS = store2->addPermRoot(drvPath, rootName);
|
||||
}
|
||||
|
|
|
@ -28,9 +28,9 @@ bool createUserEnv(EvalState & state, DrvInfos & elems,
|
|||
drvsToBuild.push_back({*drvPath});
|
||||
|
||||
debug("building user environment dependencies");
|
||||
state.store->buildPaths(
|
||||
state.ctx.store->buildPaths(
|
||||
toDerivedPaths(drvsToBuild),
|
||||
state.repair ? bmRepair : bmNormal);
|
||||
state.ctx.repair ? bmRepair : bmNormal);
|
||||
|
||||
/* Construct the whole top level derivation. */
|
||||
StorePathSet references;
|
||||
|
@ -51,9 +51,9 @@ bool createUserEnv(EvalState & state, DrvInfos & elems,
|
|||
auto system = i.querySystem(state);
|
||||
if (!system.empty())
|
||||
attrs.alloc(state.ctx.s.system).mkString(system);
|
||||
attrs.alloc(state.ctx.s.outPath).mkString(state.store->printStorePath(i.queryOutPath(state)));
|
||||
attrs.alloc(state.ctx.s.outPath).mkString(state.ctx.store->printStorePath(i.queryOutPath(state)));
|
||||
if (drvPath)
|
||||
attrs.alloc(state.ctx.s.drvPath).mkString(state.store->printStorePath(*drvPath));
|
||||
attrs.alloc(state.ctx.s.drvPath).mkString(state.ctx.store->printStorePath(*drvPath));
|
||||
|
||||
// Copy each output meant for installation.
|
||||
auto & vOutputs = attrs.alloc(state.ctx.s.outputs);
|
||||
|
@ -61,13 +61,13 @@ bool createUserEnv(EvalState & state, DrvInfos & elems,
|
|||
for (const auto & [m, j] : enumerate(outputs)) {
|
||||
(vOutputs.listElems()[m] = state.mem.allocValue())->mkString(j.first);
|
||||
auto outputAttrs = state.buildBindings(2);
|
||||
outputAttrs.alloc(state.ctx.s.outPath).mkString(state.store->printStorePath(*j.second));
|
||||
outputAttrs.alloc(state.ctx.s.outPath).mkString(state.ctx.store->printStorePath(*j.second));
|
||||
attrs.alloc(j.first).mkAttrs(outputAttrs);
|
||||
|
||||
/* This is only necessary when installing store paths, e.g.,
|
||||
`nix-env -i /nix/store/abcd...-foo'. */
|
||||
state.store->addTempRoot(*j.second);
|
||||
state.store->ensurePath(*j.second);
|
||||
state.ctx.store->addTempRoot(*j.second);
|
||||
state.ctx.store->ensurePath(*j.second);
|
||||
|
||||
references.insert(*j.second);
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ bool createUserEnv(EvalState & state, DrvInfos & elems,
|
|||
environment. */
|
||||
std::ostringstream str;
|
||||
printAmbiguous(manifest, state.ctx.symbols, str, nullptr, std::numeric_limits<int>::max());
|
||||
auto manifestFile = state.store->addTextToStore("env-manifest.nix",
|
||||
auto manifestFile = state.ctx.store->addTextToStore("env-manifest.nix",
|
||||
str.str(), references);
|
||||
|
||||
/* Get the environment builder expression. */
|
||||
|
@ -125,12 +125,12 @@ bool createUserEnv(EvalState & state, DrvInfos & elems,
|
|||
debug("building user environment");
|
||||
std::vector<StorePathWithOutputs> topLevelDrvs;
|
||||
topLevelDrvs.push_back({topLevelDrv});
|
||||
state.store->buildPaths(
|
||||
state.ctx.store->buildPaths(
|
||||
toDerivedPaths(topLevelDrvs),
|
||||
state.repair ? bmRepair : bmNormal);
|
||||
state.ctx.repair ? bmRepair : bmNormal);
|
||||
|
||||
/* Switch the current user environment to the output path. */
|
||||
auto store2 = state.store.dynamic_pointer_cast<LocalFSStore>();
|
||||
auto store2 = state.ctx.store.dynamic_pointer_cast<LocalFSStore>();
|
||||
|
||||
if (store2) {
|
||||
PathLocks lock;
|
||||
|
|
|
@ -136,7 +136,7 @@ ProfileManifest::ProfileManifest(EvalState & state, const Path & profile)
|
|||
auto & e = elem.value();
|
||||
ProfileElement element;
|
||||
for (auto & p : e["storePaths"]) {
|
||||
element.storePaths.insert(state.store->parseStorePath((std::string) p));
|
||||
element.storePaths.insert(state.ctx.store->parseStorePath((std::string) p));
|
||||
}
|
||||
element.active = e["active"];
|
||||
if (e.contains("priority")) {
|
||||
|
@ -162,10 +162,10 @@ ProfileManifest::ProfileManifest(EvalState & state, const Path & profile)
|
|||
}
|
||||
} else if (pathExists(profile + "/manifest.nix")) {
|
||||
// FIXME: needed because of pure mode; ugly.
|
||||
state.paths.allowPath(state.store->followLinksToStore(profile));
|
||||
state.paths.allowPath(state.store->followLinksToStore(profile + "/manifest.nix"));
|
||||
state.paths.allowPath(state.ctx.store->followLinksToStore(profile));
|
||||
state.paths.allowPath(state.ctx.store->followLinksToStore(profile + "/manifest.nix"));
|
||||
|
||||
auto drvInfos = queryInstalled(state, state.store->followLinksToStore(profile));
|
||||
auto drvInfos = queryInstalled(state, state.ctx.store->followLinksToStore(profile));
|
||||
|
||||
for (auto & drvInfo : drvInfos) {
|
||||
ProfileElement element;
|
||||
|
|
|
@ -585,7 +585,7 @@ string_t AttrCursor::getStringWithContext(EvalState & state)
|
|||
return o.path;
|
||||
},
|
||||
}, c.raw);
|
||||
if (!state.store->isValidPath(path)) {
|
||||
if (!state.ctx.store->isValidPath(path)) {
|
||||
valid = false;
|
||||
break;
|
||||
}
|
||||
|
@ -728,14 +728,14 @@ bool AttrCursor::isDerivation(EvalState & state)
|
|||
StorePath AttrCursor::forceDerivation(EvalState & state)
|
||||
{
|
||||
auto aDrvPath = getAttr(state, "drvPath");
|
||||
auto drvPath = state.store->parseStorePath(aDrvPath->getString(state));
|
||||
if (!state.store->isValidPath(drvPath) && !settings.readOnlyMode) {
|
||||
auto drvPath = state.ctx.store->parseStorePath(aDrvPath->getString(state));
|
||||
if (!state.ctx.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(state);
|
||||
if (!state.store->isValidPath(drvPath))
|
||||
if (!state.ctx.store->isValidPath(drvPath))
|
||||
throw Error("don't know how to recreate store derivation '%s'!",
|
||||
state.store->printStorePath(drvPath));
|
||||
state.ctx.store->printStorePath(drvPath));
|
||||
}
|
||||
return drvPath;
|
||||
}
|
||||
|
|
|
@ -826,7 +826,7 @@ std::string EvalState::mkOutputStringRaw(
|
|||
/* In practice, this is testing for the case of CA derivations, or
|
||||
dynamic derivations. */
|
||||
return optStaticOutputPath
|
||||
? store->printStorePath(std::move(*optStaticOutputPath))
|
||||
? ctx.store->printStorePath(std::move(*optStaticOutputPath))
|
||||
/* Downstream we would substitute this for an actual path once
|
||||
we build the floating CA derivation */
|
||||
: DownstreamPlaceholder::fromSingleDerivedPathBuilt(b, xpSettings).render();
|
||||
|
@ -850,16 +850,16 @@ std::string EvalState::mkSingleDerivedPathStringRaw(
|
|||
{
|
||||
return std::visit(overloaded {
|
||||
[&](const SingleDerivedPath::Opaque & o) {
|
||||
return store->printStorePath(o.path);
|
||||
return ctx.store->printStorePath(o.path);
|
||||
},
|
||||
[&](const SingleDerivedPath::Built & b) {
|
||||
auto optStaticOutputPath = std::visit(overloaded {
|
||||
[&](const SingleDerivedPath::Opaque & o) {
|
||||
auto drv = store->readDerivation(o.path);
|
||||
auto drv = ctx.store->readDerivation(o.path);
|
||||
auto i = drv.outputs.find(b.output);
|
||||
if (i == drv.outputs.end())
|
||||
throw Error("derivation '%s' does not have output '%s'", b.drvPath->to_string(*store), b.output);
|
||||
return i->second.path(*store, drv.name, b.output);
|
||||
throw Error("derivation '%s' does not have output '%s'", b.drvPath->to_string(*ctx.store), b.output);
|
||||
return i->second.path(*ctx.store, drv.name, b.output);
|
||||
},
|
||||
[&](const SingleDerivedPath::Built & o) -> std::optional<StorePath> {
|
||||
return std::nullopt;
|
||||
|
@ -2285,7 +2285,7 @@ BackedStringView EvalState::coerceToString(
|
|||
// slash, as in /foo/${x}.
|
||||
v._path
|
||||
: copyToStore
|
||||
? store->printStorePath(paths.copyPathToStore(context, v.path(), repair))
|
||||
? ctx.store->printStorePath(paths.copyPathToStore(context, v.path(), ctx.repair))
|
||||
: std::string(v.path().path.abs());
|
||||
}
|
||||
|
||||
|
@ -2390,7 +2390,7 @@ SourcePath EvalState::coerceToPath(const PosIdx pos, Value & v, NixStringContext
|
|||
StorePath EvalState::coerceToStorePath(const PosIdx pos, Value & v, NixStringContext & context, std::string_view errorCtx)
|
||||
{
|
||||
auto path = coerceToString(pos, v, context, errorCtx, false, false, true).toOwned();
|
||||
if (auto storePath = store->maybeParseStorePath(path))
|
||||
if (auto storePath = ctx.store->maybeParseStorePath(path))
|
||||
return *storePath;
|
||||
ctx.errors.make<EvalError>("path '%1%' is not in the Nix store", path).withTrace(pos, errorCtx).debugThrow();
|
||||
}
|
||||
|
@ -2444,7 +2444,7 @@ SingleDerivedPath EvalState::coerceToSingleDerivedPath(const PosIdx pos, Value &
|
|||
[&](const SingleDerivedPath::Built & b) {
|
||||
ctx.errors.make<EvalError>(
|
||||
"string '%s' has context with the output '%s' from derivation '%s', but the string is not the right placeholder for this derivation output. It should be '%s'",
|
||||
s, b.output, b.drvPath->to_string(*store), sExpected)
|
||||
s, b.output, b.drvPath->to_string(*ctx.store), sExpected)
|
||||
.withTrace(pos, errorCtx).debugThrow();
|
||||
}
|
||||
}, derivedPath.raw());
|
||||
|
|
|
@ -232,7 +232,7 @@ static Flake getFlake(
|
|||
auto flakeFile = canonPath(flakeDir + "/flake.nix", true);
|
||||
if (!isInDir(flakeFile, sourceInfo.actualPath))
|
||||
throw Error("'flake.nix' file of flake '%s' escapes from '%s'",
|
||||
lockedRef, state.store->printStorePath(sourceInfo.storePath));
|
||||
lockedRef, state.ctx.store->printStorePath(sourceInfo.storePath));
|
||||
|
||||
Flake flake {
|
||||
.originalRef = originalRef,
|
||||
|
@ -385,7 +385,7 @@ LockedFlake lockFlake(
|
|||
|
||||
if (lockFlags.applyNixConfig) {
|
||||
flake.config.apply();
|
||||
state.store->setOptions();
|
||||
state.ctx.store->setOptions();
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
|
@ -168,7 +168,7 @@ static void mkOutputString(
|
|||
.drvPath = makeConstantStorePathRef(drvPath),
|
||||
.output = o.first,
|
||||
},
|
||||
o.second.path(*state.store, Derivation::nameFromPath(drvPath), o.first));
|
||||
o.second.path(*state.ctx.store, Derivation::nameFromPath(drvPath), o.first));
|
||||
}
|
||||
|
||||
/* Load and evaluate an expression from path specified by the
|
||||
|
@ -180,16 +180,16 @@ static void import(EvalState & state, const PosIdx pos, Value & vPath, Value * v
|
|||
|
||||
// FIXME
|
||||
auto isValidDerivationInStore = [&]() -> std::optional<StorePath> {
|
||||
if (!state.store->isStorePath(path2))
|
||||
if (!state.ctx.store->isStorePath(path2))
|
||||
return std::nullopt;
|
||||
auto storePath = state.store->parseStorePath(path2);
|
||||
if (!(state.store->isValidPath(storePath) && isDerivation(path2)))
|
||||
auto storePath = state.ctx.store->parseStorePath(path2);
|
||||
if (!(state.ctx.store->isValidPath(storePath) && isDerivation(path2)))
|
||||
return std::nullopt;
|
||||
return storePath;
|
||||
};
|
||||
|
||||
if (auto storePath = isValidDerivationInStore()) {
|
||||
Derivation drv = state.store->readDerivation(*storePath);
|
||||
Derivation drv = state.ctx.store->readDerivation(*storePath);
|
||||
auto attrs = state.buildBindings(3 + drv.outputs.size());
|
||||
attrs.alloc(state.ctx.s.drvPath).mkString(path2, {
|
||||
NixStringContextElem::DrvDeep { .drvPath = *storePath },
|
||||
|
@ -970,11 +970,11 @@ drvName, Bindings * attrs, Value & v)
|
|||
[&](const NixStringContextElem::DrvDeep & d) {
|
||||
/* !!! This doesn't work if readOnlyMode is set. */
|
||||
StorePathSet refs;
|
||||
state.store->computeFSClosure(d.drvPath, refs);
|
||||
state.ctx.store->computeFSClosure(d.drvPath, refs);
|
||||
for (auto & j : refs) {
|
||||
drv.inputSrcs.insert(j);
|
||||
if (j.isDerivation()) {
|
||||
drv.inputDrvs.map[j].value = state.store->readDerivation(j).outputNames();
|
||||
drv.inputDrvs.map[j].value = state.ctx.store->readDerivation(j).outputNames();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -1031,7 +1031,7 @@ drvName, Bindings * attrs, Value & v)
|
|||
},
|
||||
};
|
||||
|
||||
drv.env["out"] = state.store->printStorePath(dof.path(*state.store, drvName, "out"));
|
||||
drv.env["out"] = state.ctx.store->printStorePath(dof.path(*state.ctx.store, drvName, "out"));
|
||||
drv.outputs.insert_or_assign("out", std::move(dof));
|
||||
}
|
||||
|
||||
|
@ -1073,7 +1073,7 @@ drvName, Bindings * attrs, Value & v)
|
|||
DerivationOutput::Deferred { });
|
||||
}
|
||||
|
||||
auto hashModulo = hashDerivationModulo(*state.store, Derivation(drv), true);
|
||||
auto hashModulo = hashDerivationModulo(*state.ctx.store, Derivation(drv), true);
|
||||
switch (hashModulo.kind) {
|
||||
case DrvHash::Kind::Regular:
|
||||
for (auto & i : outputs) {
|
||||
|
@ -1083,8 +1083,8 @@ drvName, Bindings * attrs, Value & v)
|
|||
"derivation produced no hash for output '%s'",
|
||||
i
|
||||
).atPos(v).debugThrow();
|
||||
auto outPath = state.store->makeOutputPath(i, *h, drvName);
|
||||
drv.env[i] = state.store->printStorePath(outPath);
|
||||
auto outPath = state.ctx.store->makeOutputPath(i, *h, drvName);
|
||||
drv.env[i] = state.ctx.store->printStorePath(outPath);
|
||||
drv.outputs.insert_or_assign(
|
||||
i,
|
||||
DerivationOutput::InputAddressed {
|
||||
|
@ -1101,8 +1101,8 @@ drvName, Bindings * attrs, Value & v)
|
|||
}
|
||||
|
||||
/* Write the resulting term into the Nix store directory. */
|
||||
auto drvPath = writeDerivation(*state.store, drv, state.repair);
|
||||
auto drvPathS = state.store->printStorePath(drvPath);
|
||||
auto drvPath = writeDerivation(*state.ctx.store, drv, state.ctx.repair);
|
||||
auto drvPathS = state.ctx.store->printStorePath(drvPath);
|
||||
|
||||
printMsg(lvlChatty, "instantiated '%1%' -> '%2%'", drvName, drvPathS);
|
||||
|
||||
|
@ -1110,7 +1110,7 @@ drvName, Bindings * attrs, Value & v)
|
|||
case we don't actually write store derivations, so we can't
|
||||
read them later. */
|
||||
{
|
||||
auto h = hashDerivationModulo(*state.store, drv, false);
|
||||
auto h = hashDerivationModulo(*state.ctx.store, drv, false);
|
||||
drvHashes.lock()->insert_or_assign(drvPath, h);
|
||||
}
|
||||
|
||||
|
@ -1177,14 +1177,14 @@ static void prim_storePath(EvalState & state, const PosIdx pos, Value * * args,
|
|||
/* Resolve symlinks in ‘path’, unless ‘path’ itself is a symlink
|
||||
directly in the store. The latter condition is necessary so
|
||||
e.g. nix-push does the right thing. */
|
||||
if (!state.store->isStorePath(path.abs()))
|
||||
if (!state.ctx.store->isStorePath(path.abs()))
|
||||
path = CanonPath(canonPath(path.abs(), true));
|
||||
if (!state.store->isInStore(path.abs()))
|
||||
if (!state.ctx.store->isInStore(path.abs()))
|
||||
state.ctx.errors.make<EvalError>("path '%1%' is not in the Nix store", path)
|
||||
.atPos(pos).debugThrow();
|
||||
auto path2 = state.store->toStorePath(path.abs()).first;
|
||||
auto path2 = state.ctx.store->toStorePath(path.abs()).first;
|
||||
if (!settings.readOnlyMode)
|
||||
state.store->ensurePath(path2);
|
||||
state.ctx.store->ensurePath(path2);
|
||||
context.insert(NixStringContextElem::Opaque { .path = path2 });
|
||||
v.mkString(path.abs(), context);
|
||||
}
|
||||
|
@ -1263,9 +1263,9 @@ static void prim_readFile(EvalState & state, const PosIdx pos, Value * * args, V
|
|||
path
|
||||
).atPos(pos).debugThrow();
|
||||
StorePathSet refs;
|
||||
if (state.store->isInStore(path.path.abs())) {
|
||||
if (state.ctx.store->isInStore(path.path.abs())) {
|
||||
try {
|
||||
refs = state.store->queryPathInfo(state.store->toStorePath(path.path.abs()).first)->references;
|
||||
refs = state.ctx.store->queryPathInfo(state.ctx.store->toStorePath(path.path.abs()).first)->references;
|
||||
} catch (Error &) { // FIXME: should be InvalidPathError
|
||||
}
|
||||
// Re-scan references to filter down to just the ones that actually occur in the file.
|
||||
|
@ -1471,8 +1471,8 @@ static void prim_toFile(EvalState & state, const PosIdx pos, Value * * args, Val
|
|||
}
|
||||
|
||||
auto storePath = settings.readOnlyMode
|
||||
? state.store->computeStorePathForText(name, contents, refs)
|
||||
: state.store->addTextToStore(name, contents, refs, state.repair);
|
||||
? state.ctx.store->computeStorePathForText(name, contents, refs)
|
||||
: state.ctx.store->addTextToStore(name, contents, refs, state.ctx.repair);
|
||||
|
||||
/* Note: we don't need to add `context' to the context of the
|
||||
result, since `storePath' itself has references to the paths
|
||||
|
@ -1501,12 +1501,12 @@ static void addPath(
|
|||
|
||||
StorePathSet refs;
|
||||
|
||||
if (state.store->isInStore(path)) {
|
||||
if (state.ctx.store->isInStore(path)) {
|
||||
try {
|
||||
auto [storePath, subPath] = state.store->toStorePath(path);
|
||||
auto [storePath, subPath] = state.ctx.store->toStorePath(path);
|
||||
// FIXME: we should scanForReferences on the path before adding it
|
||||
refs = state.store->queryPathInfo(storePath)->references;
|
||||
path = state.store->toRealPath(storePath) + subPath;
|
||||
refs = state.ctx.store->queryPathInfo(storePath)->references;
|
||||
path = state.ctx.store->toRealPath(storePath) + subPath;
|
||||
} catch (Error &) { // FIXME: should be InvalidPathError
|
||||
}
|
||||
}
|
||||
|
@ -1539,15 +1539,15 @@ static void addPath(
|
|||
|
||||
std::optional<StorePath> expectedStorePath;
|
||||
if (expectedHash)
|
||||
expectedStorePath = state.store->makeFixedOutputPath(name, FixedOutputInfo {
|
||||
expectedStorePath = state.ctx.store->makeFixedOutputPath(name, FixedOutputInfo {
|
||||
.method = method,
|
||||
.hash = *expectedHash,
|
||||
.references = {},
|
||||
});
|
||||
|
||||
if (!expectedHash || !state.store->isValidPath(*expectedStorePath)) {
|
||||
if (!expectedHash || !state.ctx.store->isValidPath(*expectedStorePath)) {
|
||||
auto dstPath = fetchToStore(
|
||||
*state.store, CanonPath(path), name, method, &filter, state.repair);
|
||||
*state.ctx.store, CanonPath(path), name, method, &filter, state.ctx.repair);
|
||||
if (expectedHash && expectedStorePath != dstPath)
|
||||
state.ctx.errors.make<EvalError>(
|
||||
"store path mismatch in (possibly filtered) path added from '%s'",
|
||||
|
|
|
@ -68,7 +68,7 @@ void prim_addDrvOutputDependencies(EvalState & state, const PosIdx pos, Value *
|
|||
if (!c.path.isDerivation()) {
|
||||
state.ctx.errors.make<EvalError>(
|
||||
"path '%s' is not a derivation",
|
||||
state.store->printStorePath(c.path)
|
||||
state.ctx.store->printStorePath(c.path)
|
||||
).atPos(pos).debugThrow();
|
||||
}
|
||||
return NixStringContextElem::DrvDeep {
|
||||
|
@ -129,7 +129,7 @@ void prim_getContext(EvalState & state, const PosIdx pos, Value * * args, Value
|
|||
[&](NixStringContextElem::Built && b) {
|
||||
// FIXME should eventually show string context as is, no
|
||||
// resolving here.
|
||||
auto drvPath = resolveDerivedPath(*state.store, *b.drvPath);
|
||||
auto drvPath = resolveDerivedPath(*state.ctx.store, *b.drvPath);
|
||||
contextInfos[std::move(drvPath)].outputs.emplace_back(std::move(b.output));
|
||||
},
|
||||
[&](NixStringContextElem::Opaque && o) {
|
||||
|
@ -153,7 +153,7 @@ void prim_getContext(EvalState & state, const PosIdx pos, Value * * args, Value
|
|||
for (const auto & [i, output] : enumerate(info.second.outputs))
|
||||
(outputsVal.listElems()[i] = state.mem.allocValue())->mkString(output);
|
||||
}
|
||||
attrs.alloc(state.store->printStorePath(info.first)).mkAttrs(infoAttrs);
|
||||
attrs.alloc(state.ctx.store->printStorePath(info.first)).mkAttrs(infoAttrs);
|
||||
}
|
||||
|
||||
v.mkAttrs(attrs);
|
||||
|
@ -175,14 +175,14 @@ static void prim_appendContext(EvalState & state, const PosIdx pos, Value * * ar
|
|||
auto sAllOutputs = state.ctx.symbols.create("allOutputs");
|
||||
for (auto & i : *args[1]->attrs) {
|
||||
const auto & name = state.ctx.symbols[i.name];
|
||||
if (!state.store->isStorePath(name))
|
||||
if (!state.ctx.store->isStorePath(name))
|
||||
state.ctx.errors.make<EvalError>(
|
||||
"context key '%s' is not a store path",
|
||||
name
|
||||
).atPos(i.pos).debugThrow();
|
||||
auto namePath = state.store->parseStorePath(name);
|
||||
auto namePath = state.ctx.store->parseStorePath(name);
|
||||
if (!settings.readOnlyMode)
|
||||
state.store->ensurePath(namePath);
|
||||
state.ctx.store->ensurePath(namePath);
|
||||
state.forceAttrs(*i.value, i.pos, "while evaluating the value of a string context");
|
||||
auto iter = i.value->attrs->find(state.ctx.s.path);
|
||||
if (iter != i.value->attrs->end()) {
|
||||
|
|
|
@ -19,14 +19,14 @@ static void runFetchClosureWithRewrite(EvalState & state, const PosIdx pos, Stor
|
|||
|
||||
// establish toPath or throw
|
||||
|
||||
if (!toPathMaybe || !state.store->isValidPath(*toPathMaybe)) {
|
||||
auto rewrittenPath = makeContentAddressed(fromStore, *state.store, fromPath);
|
||||
if (!toPathMaybe || !state.ctx.store->isValidPath(*toPathMaybe)) {
|
||||
auto rewrittenPath = makeContentAddressed(fromStore, *state.ctx.store, fromPath);
|
||||
if (toPathMaybe && *toPathMaybe != rewrittenPath)
|
||||
throw Error({
|
||||
.msg = HintFmt("rewriting '%s' to content-addressed form yielded '%s', while '%s' was expected",
|
||||
state.store->printStorePath(fromPath),
|
||||
state.store->printStorePath(rewrittenPath),
|
||||
state.store->printStorePath(*toPathMaybe)),
|
||||
state.ctx.store->printStorePath(fromPath),
|
||||
state.ctx.store->printStorePath(rewrittenPath),
|
||||
state.ctx.store->printStorePath(*toPathMaybe)),
|
||||
.pos = state.ctx.positions[pos]
|
||||
});
|
||||
if (!toPathMaybe)
|
||||
|
@ -34,8 +34,8 @@ static void runFetchClosureWithRewrite(EvalState & state, const PosIdx pos, Stor
|
|||
.msg = HintFmt(
|
||||
"rewriting '%s' to content-addressed form yielded '%s'\n"
|
||||
"Use this value for the 'toPath' attribute passed to 'fetchClosure'",
|
||||
state.store->printStorePath(fromPath),
|
||||
state.store->printStorePath(rewrittenPath)),
|
||||
state.ctx.store->printStorePath(fromPath),
|
||||
state.ctx.store->printStorePath(rewrittenPath)),
|
||||
.pos = state.ctx.positions[pos]
|
||||
});
|
||||
}
|
||||
|
@ -44,16 +44,16 @@ static void runFetchClosureWithRewrite(EvalState & state, const PosIdx pos, Stor
|
|||
|
||||
// check and return
|
||||
|
||||
auto resultInfo = state.store->queryPathInfo(toPath);
|
||||
auto resultInfo = state.ctx.store->queryPathInfo(toPath);
|
||||
|
||||
if (!resultInfo->isContentAddressed(*state.store)) {
|
||||
if (!resultInfo->isContentAddressed(*state.ctx.store)) {
|
||||
// We don't perform the rewriting when outPath already exists, as an optimisation.
|
||||
// However, we can quickly detect a mistake if the toPath is input addressed.
|
||||
throw Error({
|
||||
.msg = HintFmt(
|
||||
"The 'toPath' value '%s' is input-addressed, so it can't possibly be the result of rewriting to a content-addressed path.\n\n"
|
||||
"Set 'toPath' to an empty string to make Lix report the correct content-addressed path.",
|
||||
state.store->printStorePath(toPath)),
|
||||
state.ctx.store->printStorePath(toPath)),
|
||||
.pos = state.ctx.positions[pos]
|
||||
});
|
||||
}
|
||||
|
@ -66,12 +66,12 @@ static void runFetchClosureWithRewrite(EvalState & state, const PosIdx pos, Stor
|
|||
*/
|
||||
static void runFetchClosureWithContentAddressedPath(EvalState & state, const PosIdx pos, Store & fromStore, const StorePath & fromPath, Value & v) {
|
||||
|
||||
if (!state.store->isValidPath(fromPath))
|
||||
copyClosure(fromStore, *state.store, RealisedPath::Set { fromPath });
|
||||
if (!state.ctx.store->isValidPath(fromPath))
|
||||
copyClosure(fromStore, *state.ctx.store, RealisedPath::Set { fromPath });
|
||||
|
||||
auto info = state.store->queryPathInfo(fromPath);
|
||||
auto info = state.ctx.store->queryPathInfo(fromPath);
|
||||
|
||||
if (!info->isContentAddressed(*state.store)) {
|
||||
if (!info->isContentAddressed(*state.ctx.store)) {
|
||||
throw Error({
|
||||
.msg = HintFmt(
|
||||
"The 'fromPath' value '%s' is input-addressed, but 'inputAddressed' is set to 'false' (default).\n\n"
|
||||
|
@ -79,7 +79,7 @@ static void runFetchClosureWithContentAddressedPath(EvalState & state, const Pos
|
|||
" inputAddressed = true;\n\n"
|
||||
"to the 'fetchClosure' arguments.\n\n"
|
||||
"Note that to ensure authenticity input-addressed store paths, users must configure a trusted binary cache public key on their systems. This is not needed for content-addressed paths.",
|
||||
state.store->printStorePath(fromPath)),
|
||||
state.ctx.store->printStorePath(fromPath)),
|
||||
.pos = state.ctx.positions[pos]
|
||||
});
|
||||
}
|
||||
|
@ -92,17 +92,17 @@ static void runFetchClosureWithContentAddressedPath(EvalState & state, const Pos
|
|||
*/
|
||||
static void runFetchClosureWithInputAddressedPath(EvalState & state, const PosIdx pos, Store & fromStore, const StorePath & fromPath, Value & v) {
|
||||
|
||||
if (!state.store->isValidPath(fromPath))
|
||||
copyClosure(fromStore, *state.store, RealisedPath::Set { fromPath });
|
||||
if (!state.ctx.store->isValidPath(fromPath))
|
||||
copyClosure(fromStore, *state.ctx.store, RealisedPath::Set { fromPath });
|
||||
|
||||
auto info = state.store->queryPathInfo(fromPath);
|
||||
auto info = state.ctx.store->queryPathInfo(fromPath);
|
||||
|
||||
if (info->isContentAddressed(*state.store)) {
|
||||
if (info->isContentAddressed(*state.ctx.store)) {
|
||||
throw Error({
|
||||
.msg = HintFmt(
|
||||
"The store object referred to by 'fromPath' at '%s' is not input-addressed, but 'inputAddressed' is set to 'true'.\n\n"
|
||||
"Remove the 'inputAddressed' attribute (it defaults to 'false') to expect 'fromPath' to be content-addressed",
|
||||
state.store->printStorePath(fromPath)),
|
||||
state.ctx.store->printStorePath(fromPath)),
|
||||
.pos = state.ctx.positions[pos]
|
||||
});
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ static void prim_fetchMercurial(EvalState & state, const PosIdx pos, Value * * a
|
|||
auto input = fetchers::Input::fromAttrs(std::move(attrs));
|
||||
|
||||
// FIXME: use name
|
||||
auto [tree, input2] = input.fetch(state.store);
|
||||
auto [tree, input2] = input.fetch(state.ctx.store);
|
||||
|
||||
auto attrs2 = state.buildBindings(8);
|
||||
state.paths.mkStorePathString(tree.storePath, attrs2.alloc(state.ctx.s.outPath));
|
||||
|
|
|
@ -186,13 +186,13 @@ static void fetchTree(
|
|||
}
|
||||
|
||||
if (!evalSettings.pureEval && !input.isDirect())
|
||||
input = lookupInRegistries(state.store, input).first;
|
||||
input = lookupInRegistries(state.ctx.store, input).first;
|
||||
|
||||
if (evalSettings.pureEval && !input.isLocked()) {
|
||||
state.ctx.errors.make<EvalError>("in pure evaluation mode, 'fetchTree' requires a locked input").atPos(pos).debugThrow();
|
||||
}
|
||||
|
||||
auto [tree, input2] = input.fetch(state.store);
|
||||
auto [tree, input2] = input.fetch(state.ctx.store);
|
||||
|
||||
state.paths.allowPath(tree.storePath);
|
||||
|
||||
|
@ -254,7 +254,7 @@ static void fetch(EvalState & state, const PosIdx pos, Value * * args, Value & v
|
|||
|
||||
// early exit if pinned and already in the store
|
||||
if (expectedHash && expectedHash->type == HashType::SHA256) {
|
||||
auto expectedPath = state.store->makeFixedOutputPath(
|
||||
auto expectedPath = state.ctx.store->makeFixedOutputPath(
|
||||
name,
|
||||
FixedOutputInfo {
|
||||
.method = unpack ? FileIngestionMethod::Recursive : FileIngestionMethod::Flat,
|
||||
|
@ -262,7 +262,7 @@ static void fetch(EvalState & state, const PosIdx pos, Value * * args, Value & v
|
|||
.references = {}
|
||||
});
|
||||
|
||||
if (state.store->isValidPath(expectedPath)) {
|
||||
if (state.ctx.store->isValidPath(expectedPath)) {
|
||||
state.paths.allowAndSetStorePathString(expectedPath, v);
|
||||
return;
|
||||
}
|
||||
|
@ -272,13 +272,13 @@ static void fetch(EvalState & state, const PosIdx pos, Value * * args, Value & v
|
|||
// https://github.com/NixOS/nix/issues/4313
|
||||
auto storePath =
|
||||
unpack
|
||||
? fetchers::downloadTarball(state.store, *url, name, (bool) expectedHash).tree.storePath
|
||||
: fetchers::downloadFile(state.store, *url, name, (bool) expectedHash).storePath;
|
||||
? fetchers::downloadTarball(state.ctx.store, *url, name, (bool) expectedHash).tree.storePath
|
||||
: fetchers::downloadFile(state.ctx.store, *url, name, (bool) expectedHash).storePath;
|
||||
|
||||
if (expectedHash) {
|
||||
auto hash = unpack
|
||||
? state.store->queryPathInfo(storePath)->narHash
|
||||
: hashFile(HashType::SHA256, state.store->toRealPath(storePath));
|
||||
? state.ctx.store->queryPathInfo(storePath)->narHash
|
||||
: hashFile(HashType::SHA256, state.ctx.store->toRealPath(storePath));
|
||||
if (hash != *expectedHash) {
|
||||
state.ctx.errors.make<EvalError>(
|
||||
"hash mismatch in file downloaded from '%s':\n specified: %s\n got: %s",
|
||||
|
|
|
@ -235,7 +235,7 @@ private:
|
|||
NixStringContext context;
|
||||
std::string storePath;
|
||||
if (i != v.attrs->end())
|
||||
storePath = state.store->printStorePath(state.coerceToStorePath(i->pos, *i->value, context, "while evaluating the drvPath of a derivation"));
|
||||
storePath = state.ctx.store->printStorePath(state.coerceToStorePath(i->pos, *i->value, context, "while evaluating the drvPath of a derivation"));
|
||||
|
||||
if (options.ansiColors)
|
||||
output << ANSI_GREEN;
|
||||
|
|
|
@ -36,8 +36,8 @@ json printValueAsJSON(EvalState & state, bool strict,
|
|||
|
||||
case nPath:
|
||||
if (copyToStore)
|
||||
out = state.store->printStorePath(
|
||||
state.paths.copyPathToStore(context, v.path(), state.repair));
|
||||
out = state.ctx.store->printStorePath(
|
||||
state.paths.copyPathToStore(context, v.path(), state.ctx.repair));
|
||||
else
|
||||
out = v.path().path.abs();
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue