Skip to content
Snippets Groups Projects
Commit 2e210b23 authored by Eelco Dolstra's avatar Eelco Dolstra
Browse files

* Convenience option `nix-collect-garbage -d' (--delete-old): removes

  old generations of *all* profiles in /nix/var/nix/profiles, then
  runs the garbage collector.  Quick way to get rid of all old stuff.
  Of course, one cannot roll back to earlier points in time after
  this.
parent 89ac8db7
No related branches found
No related tags found
No related merge requests found
#! @shell@ -e #! @perl@ -w
exec @bindir@/nix-store --gc "$@"
use strict;
my $profilesDir = "@localstatedir@/nix/profiles";
# Process the command line arguments.
my @args = ();
my $removeOld = 0;
for my $arg (@ARGV) {
if ($arg eq "--delete-old" || $arg eq "-d") {
$removeOld = 1;
} else {
push @args, $arg;
}
}
# If `-d' was specified, remove all old generations of all profiles.
# Of course, this makes rollbacks to before this point in time
# impossible.
if ($removeOld) {
opendir DIR, $profilesDir or die;
foreach my $name (sort (readdir DIR)) {
$name = $profilesDir . "/" . $name;
if (-l $name && (readlink($name) =~ /link/)) {
print STDERR "removing old generations of profile $name\n";
system "@bindir@/nix-env", "-p", $name, "--delete-generations", "old";
}
}
closedir DIR or die;
}
# Run the actual garbage collector.
exec "@bindir@/nix-store", "--gc", @args;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment