aboutsummaryrefslogtreecommitdiff
path: root/src/nix-build
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2022-03-02 10:57:19 +0100
committerEelco Dolstra <edolstra@gmail.com>2022-03-02 23:58:58 +0100
commitb55d79728ccbd2581fa3aa7b2ec7f498aa2285d6 (patch)
tree730a2a80d984d557f3ff0c50da8916f97e6c02af /src/nix-build
parent3e3d0711d4c4409172b3e3f342e204d04d554f4b (diff)
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).
Diffstat (limited to 'src/nix-build')
-rwxr-xr-xsrc/nix-build/nix-build.cc11
1 files changed, 4 insertions, 7 deletions
diff --git a/src/nix-build/nix-build.cc b/src/nix-build/nix-build.cc
index 3d189f934..795a4f7bd 100755
--- a/src/nix-build/nix-build.cc
+++ b/src/nix-build/nix-build.cc
@@ -346,7 +346,7 @@ static void main_nix_build(int argc, char * * argv)
throw UsageError("nix-shell requires a single derivation");
auto & drvInfo = drvs.front();
- auto drv = evalStore->derivationFromPath(evalStore->parseStorePath(drvInfo.queryDrvPath()));
+ auto drv = evalStore->derivationFromPath(drvInfo.requireDrvPath());
std::vector<StorePathWithOutputs> pathsToBuild;
RealisedPath::Set pathsToCopy;
@@ -369,7 +369,7 @@ static void main_nix_build(int argc, char * * argv)
if (!drv)
throw Error("the 'bashInteractive' attribute in <nixpkgs> did not evaluate to a derivation");
- auto bashDrv = store->parseStorePath(drv->queryDrvPath());
+ auto bashDrv = drv->requireDrvPath();
pathsToBuild.push_back({bashDrv});
pathsToCopy.insert(bashDrv);
shellDrv = bashDrv;
@@ -458,10 +458,7 @@ static void main_nix_build(int argc, char * * argv)
}
}
- ParsedDerivation parsedDrv(
- StorePath(store->parseStorePath(drvInfo.queryDrvPath())),
- drv
- );
+ ParsedDerivation parsedDrv(drvInfo.requireDrvPath(), drv);
if (auto structAttrs = parsedDrv.prepareStructuredAttrs(*store, inputs)) {
auto json = structAttrs.value();
@@ -553,7 +550,7 @@ static void main_nix_build(int argc, char * * argv)
std::map<StorePath, std::pair<size_t, StringSet>> drvMap;
for (auto & drvInfo : drvs) {
- auto drvPath = store->parseStorePath(drvInfo.queryDrvPath());
+ auto drvPath = drvInfo.requireDrvPath();
auto outputName = drvInfo.queryOutputName();
if (outputName == "")