aboutsummaryrefslogtreecommitdiff
path: root/src/nix-env
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2021-03-02 03:50:41 +0000
committerJohn Ericson <John.Ericson@Obsidian.Systems>2021-04-05 08:33:00 -0400
commit255d145ba7ac907d1cba8d088da556b591627756 (patch)
tree3fe8f3721b4416699b3a1f9ddf2a5c7d17c4471f /src/nix-env
parent32f4454b9fa3ac30d58e738ece322eb19a0728ba (diff)
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).
Diffstat (limited to 'src/nix-env')
-rw-r--r--src/nix-env/nix-env.cc30
-rw-r--r--src/nix-env/user-env.cc9
2 files changed, 23 insertions, 16 deletions
diff --git a/src/nix-env/nix-env.cc b/src/nix-env/nix-env.cc
index 0f10a4cbb..af1c69b87 100644
--- a/src/nix-env/nix-env.cc
+++ b/src/nix-env/nix-env.cc
@@ -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(
diff --git a/src/nix-env/user-env.cc b/src/nix-env/user-env.cc
index 168ac492b..0ccf960fb 100644
--- a/src/nix-env/user-env.cc
+++ b/src/nix-env/user-env.cc
@@ -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>();