From 13493ef97c01a9839c340cbe4e99baae65b20e15 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 21 May 2015 15:21:38 +0200 Subject: nix-collect-garbage: Call collectGarbage() internally --- src/nix-collect-garbage/nix-collect-garbage.cc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/nix-collect-garbage/nix-collect-garbage.cc') diff --git a/src/nix-collect-garbage/nix-collect-garbage.cc b/src/nix-collect-garbage/nix-collect-garbage.cc index a8f6c03c2377..740ef88f5395 100644 --- a/src/nix-collect-garbage/nix-collect-garbage.cc +++ b/src/nix-collect-garbage/nix-collect-garbage.cc @@ -1,3 +1,4 @@ +#include "store-api.hh" #include "hash.hh" #include "shared.hh" #include "globals.hh" @@ -87,7 +88,13 @@ int main(int argc, char * * argv) if (removeOld) removeOldGenerations(profilesDir); // Run the actual garbage collector. - if (!dryRun) runProgramSimple(settings.nixBinDir + "/nix-store", Strings{"--gc"}); + if (!dryRun) { + store = openStore(false); + GCOptions options; + options.action = GCOptions::gcDeleteDead; + GCResults results; + PrintFreed freed(true, results); + store->collectGarbage(options, results); + } }); } - -- cgit 1.4.1