66e94d3275
default -> default-94-link default-82-link -> /nix/store/cc4480... default-83-link -> /nix/store/caeec8... ... default-94-link -> /nix/store/2896ca... experimental -> experimental-2-link experimental-1-link -> /nix/store/cc4480... experimental-2-link -> /nix/store/a3148f... * `--profile' / `-p' -> `--switch-profile' / `-S' * `--link' / `-l' -> `--profile' / `-p' * The default profile is stored in $prefix/var/nix/profiles. $prefix/var/nix/links is gone. Profiles can be stored anywhere. * The current profile is now referenced from ~/.nix-profile, not ~/.nix-userenv. * The roots to the garbage collector now have extension `.gcroot', not `.id'.
62 lines
1.4 KiB
Perl
Executable file
62 lines
1.4 KiB
Perl
Executable file
#! /usr/bin/perl -w
|
|
|
|
use strict;
|
|
use IPC::Open2;
|
|
|
|
my $linkdir = "@localstatedir@/nix/profiles";
|
|
my $storedir = "@prefix@/store";
|
|
|
|
my %alive;
|
|
|
|
my $keepsuccessors = 1;
|
|
my $invert = 0;
|
|
|
|
foreach my $arg (@ARGV) {
|
|
if ($arg eq "--no-successors") { $keepsuccessors = 0; }
|
|
elsif ($arg eq "--invert") { $invert = 1; }
|
|
else { die "unknown argument `$arg'" };
|
|
}
|
|
|
|
opendir(DIR, $linkdir) or die "cannot open directory $linkdir: $!";
|
|
my @links = readdir DIR or die "cannot read directory $linkdir: $!";
|
|
closedir DIR;
|
|
|
|
my @roots;
|
|
foreach my $link (@links) {
|
|
$link = $linkdir . "/" . $link;
|
|
next if (!($link =~ /.gcroot$/));
|
|
open ROOT, "<$link" or die "cannot open $link: $!";
|
|
my $root = <ROOT>;
|
|
chomp $root;
|
|
close ROOT;
|
|
push @roots, $root;
|
|
}
|
|
|
|
my $extraarg = "";
|
|
if ($keepsuccessors) { $extraarg = "--include-successors"; };
|
|
my $pid = open2(\*READ, \*WRITE, "nix-store --query --requisites $extraarg @roots")
|
|
or die "determining live paths";
|
|
close WRITE;
|
|
while (<READ>) {
|
|
chomp;
|
|
$alive{$_} = 1;
|
|
if ($invert) { print "$_\n"; };
|
|
}
|
|
close READ;
|
|
|
|
waitpid $pid, 0;
|
|
$? == 0 or die "determining live paths";
|
|
|
|
exit 0 if ($invert);
|
|
|
|
opendir(DIR, $storedir) or die "cannot open directory $storedir: $!";
|
|
my @names = readdir DIR;
|
|
closedir DIR;
|
|
|
|
foreach my $name (@names) {
|
|
next if ($name eq "." || $name eq "..");
|
|
$name = "$storedir/$name";
|
|
if (!$alive{$name}) {
|
|
print "$name\n";
|
|
}
|
|
}
|