diff --git a/src/nix/build.cc b/src/nix/build.cc index 00bda1fd1045663bb46b531599ac7b8856e192d4..cc96ac48a977d5a95e1888e24fd185c0b0806c63 100644 --- a/src/nix/build.cc +++ b/src/nix/build.cc @@ -23,7 +23,7 @@ struct CmdBuild : MixDryRun, InstallablesCommand void run(ref<Store> store) override { - auto paths = buildInstallables(store, dryRun); + auto paths = toStorePaths(store, dryRun ? DryRun : Build); printInfo("build result: %s", showPaths(paths)); } diff --git a/src/nix/command.cc b/src/nix/command.cc index 96b685a5b2eb3bb092b84bac703fa7a7aef1e2e8..6b608a708eeabe7906335cae4d9476d3d04b4812 100644 --- a/src/nix/command.cc +++ b/src/nix/command.cc @@ -115,7 +115,7 @@ void StorePathsCommand::run(ref<Store> store) } else { - for (auto & p : buildInstallables(store, false)) + for (auto & p : toStorePaths(store, NoBuild)) storePaths.push_back(p); if (recursive) { @@ -131,7 +131,7 @@ void StorePathsCommand::run(ref<Store> store) void StorePathCommand::run(ref<Store> store) { - auto storePaths = buildInstallables(store, false); + auto storePaths = toStorePaths(store, NoBuild); if (storePaths.size() != 1) throw UsageError("this command requires exactly one store path"); diff --git a/src/nix/command.hh b/src/nix/command.hh index 4800b5c912e4777aefde72ed189510db38ed60bf..eb736ce3a3e41a55c0008bf6bd0be07d8d8a3946 100644 --- a/src/nix/command.hh +++ b/src/nix/command.hh @@ -80,7 +80,9 @@ struct InstallablesCommand : virtual Args, StoreCommand std::vector<std::shared_ptr<Installable>> parseInstallables(ref<Store> store, Strings ss); - PathSet buildInstallables(ref<Store> store, bool dryRun); + enum ToStorePathsMode { Build, NoBuild, DryRun }; + + PathSet toStorePaths(ref<Store> store, ToStorePathsMode mode); ref<EvalState> getEvalState(); diff --git a/src/nix/installables.cc b/src/nix/installables.cc index 9982ff75f4f49fd6238f239eb373f2919e0d62c0..f0d5d547ca33c6bfd7a072f5fcf0500d0ce90819 100644 --- a/src/nix/installables.cc +++ b/src/nix/installables.cc @@ -214,7 +214,7 @@ std::vector<std::shared_ptr<Installable>> InstallablesCommand::parseInstallables return result; } -PathSet InstallablesCommand::buildInstallables(ref<Store> store, bool dryRun) +PathSet InstallablesCommand::toStorePaths(ref<Store> store, ToStorePathsMode mode) { PathSet buildables; @@ -223,9 +223,9 @@ PathSet InstallablesCommand::buildInstallables(ref<Store> store, bool dryRun) buildables.insert(b.begin(), b.end()); } - if (dryRun) + if (mode == DryRun) printMissing(store, buildables); - else + else if (mode == Build) store->buildPaths(buildables); PathSet outPaths; diff --git a/src/nix/run.cc b/src/nix/run.cc index bcfa74eb5f5f277a6c391baad21c8e9ddc478ad1..49fe4e7a0c6d2ed1b4e3e7eea4286b03a4b766f1 100644 --- a/src/nix/run.cc +++ b/src/nix/run.cc @@ -30,7 +30,7 @@ struct CmdRun : InstallablesCommand void run(ref<Store> store) override { - auto outPaths = buildInstallables(store, false); + auto outPaths = toStorePaths(store, Build); auto store2 = store.dynamic_pointer_cast<LocalStore>();