mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-22 14:06:16 +02:00
25 lines
522 B
Perl
Executable file
25 lines
522 B
Perl
Executable file
#! /usr/bin/perl -w
|
|
|
|
my $linkdir = "@localstatedir@/nix/links";
|
|
my $storedir = "@prefix@/store";
|
|
|
|
my %alive;
|
|
|
|
open HASHES, "nix --query --refs \$(cat $linkdir/*.hash) |" or die "in `nix -qrh'";
|
|
while (<HASHES>) {
|
|
chomp;
|
|
$alive{$_} = 1;
|
|
}
|
|
close HASHES;
|
|
|
|
opendir(DIR, $storedir) or die "cannot opendir $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";
|
|
}
|
|
}
|