make gcRootsDir local

just to avoid unecessary globals
This commit is contained in:
Jörg Thalheim 2021-03-21 18:37:15 +01:00
parent 2d58d8a513
commit b48e9667dc
No known key found for this signature in database
GPG key ID: B3F5D81B0C6967C4

View file

@ -25,11 +25,11 @@
using namespace nix; using namespace nix;
static Path gcRootsDir;
struct MyArgs : MixEvalArgs, MixCommonArgs struct MyArgs : MixEvalArgs, MixCommonArgs
{ {
Path releaseExpr; Path releaseExpr;
Path gcRootsDir;
bool flake = false; bool flake = false;
bool dryRun = false; bool dryRun = false;
size_t nrWorkers = 1; size_t nrWorkers = 1;
@ -123,7 +123,8 @@ static void worker(
EvalState & state, EvalState & state,
Bindings & autoArgs, Bindings & autoArgs,
AutoCloseFD & to, AutoCloseFD & to,
AutoCloseFD & from) AutoCloseFD & from,
const Path &gcRootsDir)
{ {
Value vTop; Value vTop;
@ -315,7 +316,7 @@ int main(int argc, char * * argv)
if (myArgs.releaseExpr == "") throw UsageError("no expression specified"); if (myArgs.releaseExpr == "") throw UsageError("no expression specified");
if (gcRootsDir == "") printMsg(lvlError, "warning: `--gc-roots-dir' not specified"); if (myArgs.gcRootsDir == "") printMsg(lvlError, "warning: `--gc-roots-dir' not specified");
struct State struct State
{ {
@ -352,7 +353,7 @@ int main(int argc, char * * argv)
try { try {
EvalState state(myArgs.searchPath, openStore()); EvalState state(myArgs.searchPath, openStore());
Bindings & autoArgs = *myArgs.getAutoArgs(state); Bindings & autoArgs = *myArgs.getAutoArgs(state);
worker(state, autoArgs, *to, *from); worker(state, autoArgs, *to, *from, myArgs.gcRootsDir);
} catch (Error & e) { } catch (Error & e) {
nlohmann::json err; nlohmann::json err;
auto msg = e.msg(); auto msg = e.msg();