* Remove old generations in all directories under
/nix/var/nix/profiles, not just in that directory itself. (NixOS puts profiles in /nix/var/nix/profiles/per-user.)
This commit is contained in:
parent
917e06bf63
commit
eb2dd4815c
1 changed files with 15 additions and 6 deletions
|
@ -21,22 +21,31 @@ for my $arg (@ARGV) {
|
||||||
# If `-d' was specified, remove all old generations of all profiles.
|
# If `-d' was specified, remove all old generations of all profiles.
|
||||||
# Of course, this makes rollbacks to before this point in time
|
# Of course, this makes rollbacks to before this point in time
|
||||||
# impossible.
|
# impossible.
|
||||||
if ($removeOld) {
|
|
||||||
|
|
||||||
opendir DIR, $profilesDir or die;
|
sub removeOldGenerations;
|
||||||
|
sub removeOldGenerations {
|
||||||
|
my $dir = shift;
|
||||||
|
|
||||||
foreach my $name (sort (readdir DIR)) {
|
my $dh;
|
||||||
$name = $profilesDir . "/" . $name;
|
opendir $dh, $dir or die;
|
||||||
|
|
||||||
|
foreach my $name (sort (readdir $dh)) {
|
||||||
|
next if $name eq "." || $name eq "..";
|
||||||
|
$name = $dir . "/" . $name;
|
||||||
if (-l $name && (readlink($name) =~ /link/)) {
|
if (-l $name && (readlink($name) =~ /link/)) {
|
||||||
print STDERR "removing old generations of profile $name\n";
|
print STDERR "removing old generations of profile $name\n";
|
||||||
system("@bindir@/nix-env", "-p", $name, "--delete-generations", "old");
|
system("@bindir@/nix-env", "-p", $name, "--delete-generations", "old");
|
||||||
}
|
}
|
||||||
|
elsif (! -l $name && -d $name) {
|
||||||
|
removeOldGenerations $name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
closedir DIR or die;
|
closedir $dh or die;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
removeOldGenerations $profilesDir if $removeOld;
|
||||||
|
|
||||||
|
|
||||||
# Run the actual garbage collector.
|
# Run the actual garbage collector.
|
||||||
exec "@bindir@/nix-store", "--gc", @args;
|
exec "@bindir@/nix-store", "--gc", @args;
|
||||||
|
|
Loading…
Reference in a new issue