mirror of
https://github.com/NixOS/nix
synced 2025-06-25 10:41:16 +02:00
Add EvalState::coerceToStorePath() helper
This is useful whenever we want to evaluate something to a store path (e.g. in get-drvs.cc). Extracted from the lazy-trees branch (where we can require that a store path must come from a store source tree accessor).
This commit is contained in:
parent
3e3d0711d4
commit
b55d79728c
13 changed files with 123 additions and 101 deletions
|
@ -61,12 +61,13 @@ void processExpr(EvalState & state, const Strings & attrPaths,
|
|||
DrvInfos drvs;
|
||||
getDerivations(state, v, "", autoArgs, drvs, false);
|
||||
for (auto & i : drvs) {
|
||||
Path drvPath = i.queryDrvPath();
|
||||
auto drvPath = i.requireDrvPath();
|
||||
auto drvPathS = state.store->printStorePath(drvPath);
|
||||
|
||||
/* What output do we want? */
|
||||
std::string outputName = i.queryOutputName();
|
||||
if (outputName == "")
|
||||
throw Error("derivation '%1%' lacks an 'outputName' attribute ", drvPath);
|
||||
throw Error("derivation '%1%' lacks an 'outputName' attribute", drvPathS);
|
||||
|
||||
if (gcRoot == "")
|
||||
printGCWarning();
|
||||
|
@ -75,9 +76,9 @@ void processExpr(EvalState & state, const Strings & attrPaths,
|
|||
if (++rootNr > 1) rootName += "-" + std::to_string(rootNr);
|
||||
auto store2 = state.store.dynamic_pointer_cast<LocalFSStore>();
|
||||
if (store2)
|
||||
drvPath = store2->addPermRoot(store2->parseStorePath(drvPath), rootName);
|
||||
drvPathS = store2->addPermRoot(drvPath, rootName);
|
||||
}
|
||||
std::cout << fmt("%s%s\n", drvPath, (outputName != "out" ? "!" + outputName : ""));
|
||||
std::cout << fmt("%s%s\n", drvPathS, (outputName != "out" ? "!" + outputName : ""));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue