diff --git a/src/nix/command.cc b/src/nix/command.cc index 2809a9b4f..a45f2888b 100644 --- a/src/nix/command.cc +++ b/src/nix/command.cc @@ -115,16 +115,8 @@ void StorePathsCommand::run(ref store) } else { - for (auto & i : installables) { - for (auto & path : i->toBuildable()) { - if (isDerivation(path)) { - Derivation drv = store->derivationFromPath(path); - for (auto & output : drv.outputs) - storePaths.push_back(output.second.path); - } else - storePaths.push_back(path); - } - } + for (auto & p : buildInstallables(store, false)) + storePaths.push_back(p); if (recursive) { PathSet closure; diff --git a/src/nix/installables.cc b/src/nix/installables.cc index ff345c45d..57580049f 100644 --- a/src/nix/installables.cc +++ b/src/nix/installables.cc @@ -228,7 +228,16 @@ PathSet InstallablesCommand::buildInstallables(ref store, bool dryRun) if (!dryRun) store->buildPaths(buildables); - return buildables; + PathSet outPaths; + for (auto & path : buildables) + if (isDerivation(path)) { + Derivation drv = store->derivationFromPath(path); + for (auto & output : drv.outputs) + outPaths.insert(output.second.path); + } else + outPaths.insert(path); + + return outPaths; } ref InstallablesCommand::getEvalState() diff --git a/src/nix/run.cc b/src/nix/run.cc index a0ce56134..bcfa74eb5 100644 --- a/src/nix/run.cc +++ b/src/nix/run.cc @@ -30,7 +30,7 @@ struct CmdRun : InstallablesCommand void run(ref store) override { - auto paths = buildInstallables(store, false); + auto outPaths = buildInstallables(store, false); auto store2 = store.dynamic_pointer_cast(); @@ -89,14 +89,6 @@ struct CmdRun : InstallablesCommand #endif } - PathSet outPaths; - for (auto & path : paths) - if (isDerivation(path)) { - Derivation drv = store->derivationFromPath(path); - for (auto & output : drv.outputs) - outPaths.insert(output.second.path); - } else - outPaths.insert(path); auto unixPath = tokenizeString(getEnv("PATH"), ":"); for (auto & path : outPaths)