refactor(tvix): Make Store::buildPaths return a Status

Make Store::buildPaths return a Status with [[nodiscard]] rather than
throwing exceptions to signal failure. This is the beginning of a long
road to refactor the entire store API to be status/statusor based
instead of using exceptions.

Change-Id: I2e32371c95a25b87ad129987c217d49c6d6e0c85
Reviewed-on: https://cl.tvl.fyi/c/depot/+/1745
Tested-by: BuildkiteCI
Reviewed-by: kanepyork <rikingcoding@gmail.com>
This commit is contained in:
Griffin Smith 2020-08-13 22:06:23 -04:00 committed by glittershark
parent aef3607bd3
commit d1c38d9597
18 changed files with 137 additions and 32 deletions

View file

@ -23,6 +23,7 @@
#include "libstore/profiles.hh"
#include "libstore/store-api.hh"
#include "libutil/json.hh"
#include "libutil/status.hh"
#include "libutil/util.hh"
#include "libutil/xml-writer.hh"
#include "nix-env/user-env.hh"
@ -720,8 +721,8 @@ static void opSet(Globals& globals, Strings opFlags, Strings opArgs) {
if (globals.dryRun) {
return;
}
globals.state->store->buildPaths(
paths, globals.state->repair != 0u ? bmRepair : bmNormal);
nix::util::OkOrThrow(globals.state->store->buildPaths(
paths, globals.state->repair != 0u ? bmRepair : bmNormal));
} else {
printMissing(globals.state->store, {drv.queryOutPath()});
if (globals.dryRun) {

View file

@ -9,6 +9,7 @@
#include "libstore/globals.hh"
#include "libstore/profiles.hh"
#include "libstore/store-api.hh"
#include "libutil/status.hh"
#include "libutil/util.hh"
namespace nix {
@ -37,8 +38,8 @@ bool createUserEnv(EvalState& state, DrvInfos& elems, const Path& profile,
}
DLOG(INFO) << "building user environment dependencies";
state.store->buildPaths(drvsToBuild,
state.repair != 0u ? bmRepair : bmNormal);
util::OkOrThrow(state.store->buildPaths(
drvsToBuild, state.repair != 0u ? bmRepair : bmNormal));
/* Construct the whole top level derivation. */
PathSet references;
@ -137,8 +138,8 @@ bool createUserEnv(EvalState& state, DrvInfos& elems, const Path& profile,
/* Realise the resulting store expression. */
DLOG(INFO) << "building user environment";
state.store->buildPaths({topLevelDrv},
state.repair != 0u ? bmRepair : bmNormal);
util::OkOrThrow(state.store->buildPaths(
{topLevelDrv}, state.repair != 0u ? bmRepair : bmNormal));
/* Switch the current user environment to the output path. */
auto store2 = state.store.dynamic_pointer_cast<LocalFSStore>();