aboutsummaryrefslogtreecommitdiff
path: root/src/libstore
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2022-03-09 12:25:35 +0100
committerEelco Dolstra <edolstra@gmail.com>2022-03-09 12:25:35 +0100
commit761242afa08d5c9280ba6bd63a310b4334b83bb2 (patch)
tree7509dfda4c52ecab6e972e3f1ed9d3b1d0360b5b /src/libstore
parenta4604f19284254ac98f19a13ff7c2216de7fe176 (diff)
BuildResult: Use DerivedPath
Diffstat (limited to 'src/libstore')
-rw-r--r--src/libstore/build-result.hh6
-rw-r--r--src/libstore/build/derivation-goal.cc6
-rw-r--r--src/libstore/build/drv-output-substitution-goal.cc8
-rw-r--r--src/libstore/build/entry-points.cc15
-rw-r--r--src/libstore/build/goal.hh4
-rw-r--r--src/libstore/build/substitution-goal.cc3
-rw-r--r--src/libstore/legacy-ssh-store.cc4
-rw-r--r--src/libstore/remote-store.cc25
8 files changed, 37 insertions, 34 deletions
diff --git a/src/libstore/build-result.hh b/src/libstore/build-result.hh
index c16027808..d39d23a76 100644
--- a/src/libstore/build-result.hh
+++ b/src/libstore/build-result.hh
@@ -64,13 +64,13 @@ struct BuildResult
non-determinism.) */
bool isNonDeterministic = false;
+ /* The derivation we built or the store path we substituted. */
+ DerivedPath path;
+
/* For derivations, the derivation path and the wanted outputs. */
std::optional<StorePath> drvPath;
DrvOutputs builtOutputs;
- /* For substitutions, the substituted path. */
- std::optional<StorePath> outPath;
-
/* The start/stop times of the build (or one of the rounds, if it
was repeated). */
time_t startTime = 0, stopTime = 0;
diff --git a/src/libstore/build/derivation-goal.cc b/src/libstore/build/derivation-goal.cc
index cd582bb01..325635e2e 100644
--- a/src/libstore/build/derivation-goal.cc
+++ b/src/libstore/build/derivation-goal.cc
@@ -66,7 +66,7 @@ namespace nix {
DerivationGoal::DerivationGoal(const StorePath & drvPath,
const StringSet & wantedOutputs, Worker & worker, BuildMode buildMode)
- : Goal(worker)
+ : Goal(worker, DerivedPath::Built { .drvPath = drvPath, .outputs = wantedOutputs })
, useDerivation(true)
, drvPath(drvPath)
, wantedOutputs(wantedOutputs)
@@ -85,7 +85,7 @@ DerivationGoal::DerivationGoal(const StorePath & drvPath,
DerivationGoal::DerivationGoal(const StorePath & drvPath, const BasicDerivation & drv,
const StringSet & wantedOutputs, Worker & worker, BuildMode buildMode)
- : Goal(worker)
+ : Goal(worker, DerivedPath::Built { .drvPath = drvPath, .outputs = wantedOutputs })
, useDerivation(false)
, drvPath(drvPath)
, wantedOutputs(wantedOutputs)
@@ -509,7 +509,7 @@ void DerivationGoal::inputsRealised()
state = &DerivationGoal::tryToBuild;
worker.wakeUp(shared_from_this());
- buildResult = BuildResult();
+ buildResult = BuildResult { .path = buildResult.path };
}
void DerivationGoal::started()
diff --git a/src/libstore/build/drv-output-substitution-goal.cc b/src/libstore/build/drv-output-substitution-goal.cc
index 946ec1aff..e50292c1e 100644
--- a/src/libstore/build/drv-output-substitution-goal.cc
+++ b/src/libstore/build/drv-output-substitution-goal.cc
@@ -6,8 +6,12 @@
namespace nix {
-DrvOutputSubstitutionGoal::DrvOutputSubstitutionGoal(const DrvOutput& id, Worker & worker, RepairFlag repair, std::optional<ContentAddress> ca)
- : Goal(worker)
+DrvOutputSubstitutionGoal::DrvOutputSubstitutionGoal(
+ const DrvOutput & id,
+ Worker & worker,
+ RepairFlag repair,
+ std::optional<ContentAddress> ca)
+ : Goal(worker, DerivedPath::Opaque { StorePath::dummy })
, id(id)
{
state = &DrvOutputSubstitutionGoal::init;
diff --git a/src/libstore/build/entry-points.cc b/src/libstore/build/entry-points.cc
index b2f87aa82..bea7363db 100644
--- a/src/libstore/build/entry-points.cc
+++ b/src/libstore/build/entry-points.cc
@@ -82,17 +82,16 @@ BuildResult Store::buildDerivation(const StorePath & drvPath, const BasicDerivat
Worker worker(*this, *this);
auto goal = worker.makeBasicDerivationGoal(drvPath, drv, {}, buildMode);
- BuildResult result;
-
try {
worker.run(Goals{goal});
- result = goal->buildResult;
+ return goal->buildResult;
} catch (Error & e) {
- result.status = BuildResult::MiscFailure;
- result.errorMsg = e.msg();
- }
-
- return result;
+ return BuildResult {
+ .status = BuildResult::MiscFailure,
+ .errorMsg = e.msg(),
+ .path = DerivedPath::Built { .drvPath = drvPath },
+ };
+ };
}
diff --git a/src/libstore/build/goal.hh b/src/libstore/build/goal.hh
index fcf3d0084..07c752bb9 100644
--- a/src/libstore/build/goal.hh
+++ b/src/libstore/build/goal.hh
@@ -62,7 +62,9 @@ struct Goal : public std::enable_shared_from_this<Goal>
/* Exception containing an error message, if any. */
std::optional<Error> ex;
- Goal(Worker & worker) : worker(worker)
+ Goal(Worker & worker, DerivedPath path)
+ : worker(worker)
+ , buildResult { .path = std::move(path) }
{
nrFailed = nrNoSubstituters = nrIncompleteClosure = 0;
exitCode = ecBusy;
diff --git a/src/libstore/build/substitution-goal.cc b/src/libstore/build/substitution-goal.cc
index ec500baf8..31e6dbc9f 100644
--- a/src/libstore/build/substitution-goal.cc
+++ b/src/libstore/build/substitution-goal.cc
@@ -6,7 +6,7 @@
namespace nix {
PathSubstitutionGoal::PathSubstitutionGoal(const StorePath & storePath, Worker & worker, RepairFlag repair, std::optional<ContentAddress> ca)
- : Goal(worker)
+ : Goal(worker, DerivedPath::Opaque { storePath })
, storePath(storePath)
, repair(repair)
, ca(ca)
@@ -26,7 +26,6 @@ PathSubstitutionGoal::~PathSubstitutionGoal()
void PathSubstitutionGoal::done(ExitCode result, BuildResult::Status status)
{
- buildResult.outPath = storePath;
buildResult.status = status;
amDone(result);
}
diff --git a/src/libstore/legacy-ssh-store.cc b/src/libstore/legacy-ssh-store.cc
index 16c2b90c6..dd34b19c6 100644
--- a/src/libstore/legacy-ssh-store.cc
+++ b/src/libstore/legacy-ssh-store.cc
@@ -279,7 +279,7 @@ public:
conn->to.flush();
- BuildResult status;
+ BuildResult status { .path = DerivedPath::Built { .drvPath = drvPath } };
status.status = (BuildResult::Status) readInt(conn->from);
conn->from >> status.errorMsg;
@@ -317,7 +317,7 @@ public:
conn->to.flush();
- BuildResult result;
+ BuildResult result { .path = DerivedPath::Opaque { StorePath::dummy } };
result.status = (BuildResult::Status) readInt(conn->from);
if (!result.success()) {
diff --git a/src/libstore/remote-store.cc b/src/libstore/remote-store.cc
index a0883db11..347e32094 100644
--- a/src/libstore/remote-store.cc
+++ b/src/libstore/remote-store.cc
@@ -93,7 +93,8 @@ void write(const Store & store, Sink & out, const DrvOutput & drvOutput)
BuildResult read(const Store & store, Source & from, Phantom<BuildResult> _)
{
- BuildResult res;
+ auto path = worker_proto::read(store, from, Phantom<DerivedPath> {});
+ BuildResult res { .path = path };
res.status = (BuildResult::Status) readInt(from);
from
>> res.errorMsg
@@ -101,14 +102,13 @@ BuildResult read(const Store & store, Source & from, Phantom<BuildResult> _)
>> res.isNonDeterministic
>> res.startTime
>> res.stopTime;
- res.drvPath = worker_proto::read(store, from, Phantom<std::optional<StorePath>> {});
res.builtOutputs = worker_proto::read(store, from, Phantom<DrvOutputs> {});
- res.outPath = worker_proto::read(store, from, Phantom<std::optional<StorePath>> {});
return res;
}
void write(const Store & store, Sink & to, const BuildResult & res)
{
+ worker_proto::write(store, to, res.path);
to
<< res.status
<< res.errorMsg
@@ -116,9 +116,7 @@ void write(const Store & store, Sink & to, const BuildResult & res)
<< res.isNonDeterministic
<< res.startTime
<< res.stopTime;
- worker_proto::write(store, to, res.drvPath);
worker_proto::write(store, to, res.builtOutputs);
- worker_proto::write(store, to, res.outPath);
}
@@ -842,15 +840,16 @@ std::vector<BuildResult> RemoteStore::buildPathsWithResults(
std::visit(
overloaded {
[&](const DerivedPath::Opaque & bo) {
- BuildResult res;
- res.status = BuildResult::Substituted;
- res.outPath = bo.path;
- results.push_back(res);
+ results.push_back(BuildResult {
+ .status = BuildResult::Substituted,
+ .path = bo,
+ });
},
[&](const DerivedPath::Built & bfd) {
- BuildResult res;
- res.status = BuildResult::Built;
- res.drvPath = bfd.drvPath;
+ BuildResult res {
+ .status = BuildResult::Built,
+ .path = bfd,
+ };
OutputPathMap outputs;
auto drv = evalStore->readDerivation(bfd.drvPath);
@@ -905,7 +904,7 @@ BuildResult RemoteStore::buildDerivation(const StorePath & drvPath, const BasicD
writeDerivation(conn->to, *this, drv);
conn->to << buildMode;
conn.processStderr();
- BuildResult res;
+ BuildResult res { .path = DerivedPath::Built { .drvPath = drvPath } };
res.status = (BuildResult::Status) readInt(conn->from);
conn->from >> res.errorMsg;
if (GET_PROTOCOL_MINOR(conn->daemonVersion) >= 29) {