aboutsummaryrefslogtreecommitdiff
path: root/src/nix-collect-garbage/nix-collect-garbage.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/nix-collect-garbage/nix-collect-garbage.cc')
-rw-r--r--src/nix-collect-garbage/nix-collect-garbage.cc6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/nix-collect-garbage/nix-collect-garbage.cc b/src/nix-collect-garbage/nix-collect-garbage.cc
index 366a378a1..ae75fd621 100644
--- a/src/nix-collect-garbage/nix-collect-garbage.cc
+++ b/src/nix-collect-garbage/nix-collect-garbage.cc
@@ -45,7 +45,11 @@ void removeOldGenerations(std::string dir)
if (link.find("link") != string::npos) {
printMsg(lvlInfo, format("removing old generations of profile %1%") % path);
- runProgramSimple(settings.nixBinDir + "/nix-env", Strings{"-p", path, "--delete-generations", gen, dryRun ? "--dry-run" : ""});
+ auto args = Strings{"-p", path, "--delete-generations", gen};
+ if (dryRun) {
+ args.push_back("--dry-run");
+ }
+ runProgramSimple(settings.nixBinDir + "/nix-env", args);
}
} else if (type == DT_DIR) {
removeOldGenerations(path);