mirror of
https://github.com/NixOS/nix
synced 2025-07-06 21:41:48 +02:00
Use BuildableReq
for buildPaths
and ensurePath
This avoids an ambiguity where the `StorePathWithOutputs { drvPath, {} }` could mean "build `brvPath`" or "substitute `drvPath`" depending on context. It also brings the internals closer in line to the new CLI, by generalizing the `Buildable` type is used there and makes that distinction already. In doing so, relegate `StorePathWithOutputs` to being a type just for backwards compatibility (CLI and RPC).
This commit is contained in:
parent
32f4454b9f
commit
255d145ba7
31 changed files with 364 additions and 126 deletions
|
@ -6,6 +6,7 @@
|
|||
#include "globals.hh"
|
||||
#include "names.hh"
|
||||
#include "profiles.hh"
|
||||
#include "path-with-outputs.hh"
|
||||
#include "shared.hh"
|
||||
#include "store-api.hh"
|
||||
#include "local-fs-store.hh"
|
||||
|
@ -418,13 +419,13 @@ static void queryInstSources(EvalState & state,
|
|||
|
||||
static void printMissing(EvalState & state, DrvInfos & elems)
|
||||
{
|
||||
std::vector<StorePathWithOutputs> targets;
|
||||
std::vector<BuildableReq> targets;
|
||||
for (auto & i : elems) {
|
||||
Path drvPath = i.queryDrvPath();
|
||||
if (drvPath != "")
|
||||
targets.push_back({state.store->parseStorePath(drvPath)});
|
||||
targets.push_back(BuildableReqFromDrv{state.store->parseStorePath(drvPath)});
|
||||
else
|
||||
targets.push_back({state.store->parseStorePath(i.queryOutPath())});
|
||||
targets.push_back(BuildableOpaque{state.store->parseStorePath(i.queryOutPath())});
|
||||
}
|
||||
|
||||
printMissing(state.store, targets);
|
||||
|
@ -693,17 +694,18 @@ static void opSet(Globals & globals, Strings opFlags, Strings opArgs)
|
|||
if (globals.forceName != "")
|
||||
drv.setName(globals.forceName);
|
||||
|
||||
if (drv.queryDrvPath() != "") {
|
||||
std::vector<StorePathWithOutputs> paths{{globals.state->store->parseStorePath(drv.queryDrvPath())}};
|
||||
printMissing(globals.state->store, paths);
|
||||
if (globals.dryRun) return;
|
||||
globals.state->store->buildPaths(paths, globals.state->repair ? bmRepair : bmNormal);
|
||||
} else {
|
||||
printMissing(globals.state->store,
|
||||
{{globals.state->store->parseStorePath(drv.queryOutPath())}});
|
||||
if (globals.dryRun) return;
|
||||
globals.state->store->ensurePath(globals.state->store->parseStorePath(drv.queryOutPath()));
|
||||
}
|
||||
std::vector<BuildableReq> paths {
|
||||
(drv.queryDrvPath() != "")
|
||||
? (BuildableReq) (BuildableReqFromDrv {
|
||||
globals.state->store->parseStorePath(drv.queryDrvPath())
|
||||
})
|
||||
: (BuildableReq) (BuildableOpaque {
|
||||
globals.state->store->parseStorePath(drv.queryOutPath())
|
||||
}),
|
||||
};
|
||||
printMissing(globals.state->store, paths);
|
||||
if (globals.dryRun) return;
|
||||
globals.state->store->buildPaths(paths, globals.state->repair ? bmRepair : bmNormal);
|
||||
|
||||
debug(format("switching to new user environment"));
|
||||
Path generation = createGeneration(
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#include "util.hh"
|
||||
#include "derivations.hh"
|
||||
#include "store-api.hh"
|
||||
#include "path-with-outputs.hh"
|
||||
#include "local-fs-store.hh"
|
||||
#include "globals.hh"
|
||||
#include "shared.hh"
|
||||
|
@ -41,7 +42,9 @@ bool createUserEnv(EvalState & state, DrvInfos & elems,
|
|||
drvsToBuild.push_back({state.store->parseStorePath(i.queryDrvPath())});
|
||||
|
||||
debug(format("building user environment dependencies"));
|
||||
state.store->buildPaths(drvsToBuild, state.repair ? bmRepair : bmNormal);
|
||||
state.store->buildPaths(
|
||||
toBuildableReqs(drvsToBuild),
|
||||
state.repair ? bmRepair : bmNormal);
|
||||
|
||||
/* Construct the whole top level derivation. */
|
||||
StorePathSet references;
|
||||
|
@ -136,7 +139,9 @@ bool createUserEnv(EvalState & state, DrvInfos & elems,
|
|||
debug("building user environment");
|
||||
std::vector<StorePathWithOutputs> topLevelDrvs;
|
||||
topLevelDrvs.push_back({topLevelDrv});
|
||||
state.store->buildPaths(topLevelDrvs, state.repair ? bmRepair : bmNormal);
|
||||
state.store->buildPaths(
|
||||
toBuildableReqs(topLevelDrvs),
|
||||
state.repair ? bmRepair : bmNormal);
|
||||
|
||||
/* Switch the current user environment to the output path. */
|
||||
auto store2 = state.store.dynamic_pointer_cast<LocalFSStore>();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue