mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-29 17:16:15 +02:00
* A garbage collector for installed packages. nix-collect-garbage
doesn't actually delete any packages, it just prints their descriptor hashes. So we can do nix info $(nix-collect-garbage) to print out the ids of the packages that would be deleted, and nix delpkg $(nix-collect-garbage) to actually delete them.
This commit is contained in:
parent
30a6122f80
commit
f7526febe4
2 changed files with 23 additions and 1 deletions
|
@ -1,4 +1,4 @@
|
||||||
bin_SCRIPTS = nix-generate-regscript nix-switch
|
bin_SCRIPTS = nix-generate-regscript nix-switch nix-collect-garbage
|
||||||
|
|
||||||
install-exec-local:
|
install-exec-local:
|
||||||
$(INSTALL) -d $(sysconfdir)/profile.d
|
$(INSTALL) -d $(sysconfdir)/profile.d
|
||||||
|
|
22
scripts/nix-collect-garbage
Executable file
22
scripts/nix-collect-garbage
Executable file
|
@ -0,0 +1,22 @@
|
||||||
|
#! /usr/bin/perl -w
|
||||||
|
|
||||||
|
my $prefix = $ENV{"NIX"} || "/nix"; # !!! use prefix
|
||||||
|
my $linkdir = "$prefix/var/nix/links";
|
||||||
|
|
||||||
|
my %alive;
|
||||||
|
|
||||||
|
open HASHES, "nix closure \$(cat $linkdir/*.hash) |";
|
||||||
|
while (<HASHES>) {
|
||||||
|
chomp;
|
||||||
|
$alive{$_} = 1;
|
||||||
|
}
|
||||||
|
close HASHES;
|
||||||
|
|
||||||
|
open HASHES, "nix listinst |";
|
||||||
|
while (<HASHES>) {
|
||||||
|
chomp;
|
||||||
|
if (!$alive{$_}) {
|
||||||
|
print "$_\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
close HASHES;
|
Loading…
Reference in a new issue