forked from lix-project/lix
f8d91f20e6
a mapping from the hash to a url has been registered through `nix regurl'. * Bug fix in nix: don't pollute stdout when running tar, it made nix-switch barf. * Bug fix in nix-push-prebuilts: don't create a subdirectory on the target when rsync'ing.
43 lines
1.1 KiB
Perl
Executable file
43 lines
1.1 KiB
Perl
Executable file
#! /usr/bin/perl -w
|
|
|
|
my $prefix = $ENV{"NIX"} || "/nix"; # !!! use prefix
|
|
my $etcdir = "$prefix/etc/nix";
|
|
my $exportdir = "$prefix/var/nix/prebuilts/exports";
|
|
my $knowns = "$prefix/var/nix/known-prebuilts";
|
|
|
|
# For performance, put the known hashes in an associative array.
|
|
my %knowns = ();
|
|
open KNOWNS, "<$knowns";
|
|
while (<KNOWNS>) {
|
|
next unless /([0-9a-z]{32})/;
|
|
$knowns{$1} = 1;
|
|
}
|
|
close KNOWNS;
|
|
|
|
# For each installed package, check whether a prebuilt is known.
|
|
|
|
open PKGS, "nix listinst|";
|
|
|
|
while (<PKGS>) {
|
|
chomp;
|
|
next unless /([0-9a-z]{32})/;
|
|
my $pkghash = $1;
|
|
if (!defined $knowns{$1}) {
|
|
# No known prebuilt exists for this package; so export it.
|
|
print "exporting $pkghash...\n";
|
|
system "nix export '$exportdir' $pkghash";
|
|
if ($?) { die "`nix export' failed"; }
|
|
}
|
|
}
|
|
|
|
close PKGS;
|
|
|
|
# Push the prebuilts to the server. !!! FIXME
|
|
|
|
system "rsync -av -e ssh '$exportdir'/ losser:/home/eelco/public_html/nix-prebuilts/";
|
|
|
|
# Rerun `nix-pull-prebuilts' to rescan the prebuilt source locations.
|
|
|
|
print "running nix-pull-prebuilts...";
|
|
system "nix-pull-prebuilts";
|