forked from lix-project/lix
* Made nix-push much faster.
This commit is contained in:
parent
4ce652640b
commit
b9c9b461ea
|
@ -1,6 +1,9 @@
|
|||
#! /usr/bin/perl -w
|
||||
|
||||
my @pushlist;
|
||||
my $fixfile = "/tmp/nix-push-tmp.fix";
|
||||
open FIX, ">$fixfile";
|
||||
print FIX "[";
|
||||
my $first = 1;
|
||||
|
||||
foreach my $id (@ARGV) {
|
||||
|
||||
|
@ -35,6 +38,7 @@ foreach my $id (@ARGV) {
|
|||
foreach my $path (@paths) {
|
||||
|
||||
next unless ($path =~ /\/([0-9a-z]{32})[^\/]*/);
|
||||
print "$path\n";
|
||||
my $pathid = $1;
|
||||
|
||||
# Construct a name for the Nix archive. If the file is an
|
||||
|
@ -51,28 +55,39 @@ foreach my $id (@ARGV) {
|
|||
"[ (\"path\", Slice([\"$pathid\"], [(\"$path\", \"$pathid\", [])]))" .
|
||||
"])";
|
||||
|
||||
my $fixfile = "/tmp/nix-push-tmp.fix";
|
||||
open FIX, ">$fixfile";
|
||||
print FIX "," unless ($first);
|
||||
$first = 0;
|
||||
print FIX $fixexpr;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
print FIX "]";
|
||||
close FIX;
|
||||
|
||||
# Instantiate a Nix expression from the Fix expression.
|
||||
my $nid = `fix $fixfile`;
|
||||
$? and die "instantiating Nix archive expression";
|
||||
chomp $nid;
|
||||
die unless $nid =~ /^([0-9a-z]{32})$/;
|
||||
my @nids;
|
||||
print STDERR "running fix...\n";
|
||||
open NIDS, "fix $fixfile |" or die "cannot run fix";
|
||||
while (<NIDS>) {
|
||||
chomp;
|
||||
die unless /^([0-9a-z]{32})$/;
|
||||
push @nids, $1;
|
||||
}
|
||||
|
||||
|
||||
# Realise the Nix expression.
|
||||
system "nix --install $nid";
|
||||
my @pushlist;
|
||||
print STDERR "creating archives...\n";
|
||||
system "nix --install @nids > /dev/null";
|
||||
if ($?) { die "`nix --install' failed"; }
|
||||
my $npath = `nix --query --list $nid 2> /dev/null`;
|
||||
$? and die "`nix --query --list' failed";
|
||||
chomp $npath;
|
||||
|
||||
push @pushlist, "$npath/*";
|
||||
|
||||
print "$path -> $npath\n";
|
||||
}
|
||||
open NIDS, "nix --query --list @nids |" or die "cannot run nix";
|
||||
while (<NIDS>) {
|
||||
chomp;
|
||||
die unless (/^\//);
|
||||
print "$_\n";
|
||||
push @pushlist, "$_/*";
|
||||
}
|
||||
|
||||
# Push the prebuilts to the server. !!! FIXME
|
||||
|
|
Loading…
Reference in a new issue