aboutsummaryrefslogtreecommitdiff
path: root/src/nix
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
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')
-rw-r--r--src/nix/bundle.cc4
-rw-r--r--src/nix/develop.cc3
-rw-r--r--src/nix/flake.cc5
-rw-r--r--src/nix/profile.cc15
-rw-r--r--src/nix/run.cc2
5 files changed, 17 insertions, 12 deletions
diff --git a/src/nix/bundle.cc b/src/nix/bundle.cc
index 48f4eb6e3..e86fbb3f7 100644
--- a/src/nix/bundle.cc
+++ b/src/nix/bundle.cc
@@ -70,7 +70,7 @@ struct CmdBundle : InstallableCommand
auto evalState = getEvalState();
auto app = installable->toApp(*evalState);
- store->buildPaths(app.context);
+ store->buildPaths(toBuildableReqs(app.context));
auto [bundlerFlakeRef, bundlerName] = parseFlakeRefWithFragment(bundler, absPath("."));
const flake::LockFlags lockFlags{ .writeLockFile = false };
@@ -110,7 +110,7 @@ struct CmdBundle : InstallableCommand
StorePath outPath = store->parseStorePath(evalState->coerceToPath(*attr2->pos, *attr2->value, context2));
- store->buildPaths({{drvPath}});
+ store->buildPaths({ BuildableReqFromDrv { drvPath } });
auto outPathS = store->printStorePath(outPath);
diff --git a/src/nix/develop.cc b/src/nix/develop.cc
index d0b140570..616e2073e 100644
--- a/src/nix/develop.cc
+++ b/src/nix/develop.cc
@@ -3,6 +3,7 @@
#include "common-args.hh"
#include "shared.hh"
#include "store-api.hh"
+#include "path-with-outputs.hh"
#include "derivations.hh"
#include "affinity.hh"
#include "progress-bar.hh"
@@ -159,7 +160,7 @@ StorePath getDerivationEnvironment(ref<Store> store, const StorePath & drvPath)
auto shellDrvPath = writeDerivation(*store, drv);
/* Build the derivation. */
- store->buildPaths({{shellDrvPath}});
+ store->buildPaths({BuildableReqFromDrv{shellDrvPath}});
for (auto & [_0, outputAndOptPath] : drv.outputsAndOptPaths(*store)) {
auto & [_1, optPath] = outputAndOptPath;
diff --git a/src/nix/flake.cc b/src/nix/flake.cc
index a2b6c0303..9d6d22a43 100644
--- a/src/nix/flake.cc
+++ b/src/nix/flake.cc
@@ -7,6 +7,7 @@
#include "get-drvs.hh"
#include "store-api.hh"
#include "derivations.hh"
+#include "path-with-outputs.hh"
#include "attr-path.hh"
#include "fetchers.hh"
#include "registry.hh"
@@ -292,7 +293,7 @@ struct CmdFlakeCheck : FlakeCommand
}
};
- std::vector<StorePathWithOutputs> drvPaths;
+ std::vector<BuildableReq> drvPaths;
auto checkApp = [&](const std::string & attrPath, Value & v, const Pos & pos) {
try {
@@ -461,7 +462,7 @@ struct CmdFlakeCheck : FlakeCommand
fmt("%s.%s.%s", name, attr.name, attr2.name),
*attr2.value, *attr2.pos);
if ((std::string) attr.name == settings.thisSystem.get())
- drvPaths.push_back({drvPath});
+ drvPaths.push_back(BuildableReqFromDrv{drvPath});
}
}
}
diff --git a/src/nix/profile.cc b/src/nix/profile.cc
index 4d275f577..b96e71844 100644
--- a/src/nix/profile.cc
+++ b/src/nix/profile.cc
@@ -233,7 +233,7 @@ struct CmdProfileInstall : InstallablesCommand, MixDefaultProfile
{
ProfileManifest manifest(*getEvalState(), *profile);
- std::vector<StorePathWithOutputs> pathsToBuild;
+ std::vector<BuildableReq> pathsToBuild;
for (auto & installable : installables) {
if (auto installable2 = std::dynamic_pointer_cast<InstallableFlake>(installable)) {
@@ -249,7 +249,7 @@ struct CmdProfileInstall : InstallablesCommand, MixDefaultProfile
attrPath,
};
- pathsToBuild.push_back({drv.drvPath, StringSet{drv.outputName}});
+ pathsToBuild.push_back(BuildableReqFromDrv{drv.drvPath, StringSet{drv.outputName}});
manifest.elements.emplace_back(std::move(element));
} else {
@@ -260,12 +260,15 @@ struct CmdProfileInstall : InstallablesCommand, MixDefaultProfile
std::visit(overloaded {
[&](BuildableOpaque bo) {
- pathsToBuild.push_back({bo.path, {}});
+ pathsToBuild.push_back(bo);
element.storePaths.insert(bo.path);
},
[&](BuildableFromDrv bfd) {
+ // TODO: Why are we querying if we know the output
+ // names already? Is it just to figure out what the
+ // default one is?
for (auto & output : store->queryDerivationOutputMap(bfd.drvPath)) {
- pathsToBuild.push_back({bfd.drvPath, {output.first}});
+ pathsToBuild.push_back(BuildableReqFromDrv{bfd.drvPath, {output.first}});
element.storePaths.insert(output.second);
}
},
@@ -388,7 +391,7 @@ struct CmdProfileUpgrade : virtual SourceExprCommand, MixDefaultProfile, MixProf
auto matchers = getMatchers(store);
// FIXME: code duplication
- std::vector<StorePathWithOutputs> pathsToBuild;
+ std::vector<BuildableReq> pathsToBuild;
for (size_t i = 0; i < manifest.elements.size(); ++i) {
auto & element(manifest.elements[i]);
@@ -423,7 +426,7 @@ struct CmdProfileUpgrade : virtual SourceExprCommand, MixDefaultProfile, MixProf
attrPath,
};
- pathsToBuild.push_back({drv.drvPath, StringSet{"out"}}); // FIXME
+ pathsToBuild.push_back(BuildableReqFromDrv{drv.drvPath, {"out"}}); // FIXME
}
}
diff --git a/src/nix/run.cc b/src/nix/run.cc
index ec9388234..2e9bb41cc 100644
--- a/src/nix/run.cc
+++ b/src/nix/run.cc
@@ -182,7 +182,7 @@ struct CmdRun : InstallableCommand, RunCommon
auto app = installable->toApp(*state);
- state->store->buildPaths(app.context);
+ state->store->buildPaths(toBuildableReqs(app.context));
Strings allArgs{app.program};
for (auto & i : args) allArgs.push_back(i);