forked from lix-project/lix
* Made nix-pull much faster by performing all Fix instantiations at
the same time.
This commit is contained in:
parent
17f05dba77
commit
fd30f52cfc
|
@ -3,9 +3,15 @@
|
||||||
my $tmpfile = "@localstatedir@/nix/pull.tmp";
|
my $tmpfile = "@localstatedir@/nix/pull.tmp";
|
||||||
my $conffile = "@sysconfdir@/nix/prebuilts.conf";
|
my $conffile = "@sysconfdir@/nix/prebuilts.conf";
|
||||||
|
|
||||||
|
my @ids;
|
||||||
my @subs;
|
my @subs;
|
||||||
my @sucs;
|
my @sucs;
|
||||||
|
|
||||||
|
my $fixfile = "/tmp/nix-pull-tmp.fix";
|
||||||
|
open FIX, ">$fixfile";
|
||||||
|
print FIX "[";
|
||||||
|
my $first = 1;
|
||||||
|
|
||||||
open CONFFILE, "<$conffile";
|
open CONFFILE, "<$conffile";
|
||||||
|
|
||||||
while (<CONFFILE>) {
|
while (<CONFFILE>) {
|
||||||
|
@ -41,7 +47,7 @@ while (<CONFFILE>) {
|
||||||
$outname = "unnamed";
|
$outname = "unnamed";
|
||||||
}
|
}
|
||||||
|
|
||||||
print "registering $id -> $url/$fn\n";
|
print STDERR "$id ($outname)\n";
|
||||||
|
|
||||||
# Construct a Fix expression that fetches and unpacks a
|
# Construct a Fix expression that fetches and unpacks a
|
||||||
# Nix archive from the network.
|
# Nix archive from the network.
|
||||||
|
@ -55,23 +61,14 @@ while (<CONFFILE>) {
|
||||||
", (\"id\", \"$id\")" .
|
", (\"id\", \"$id\")" .
|
||||||
"])";
|
"])";
|
||||||
|
|
||||||
my $fixfile = "/tmp/nix-pull-tmp.fix";
|
print FIX "," unless ($first);
|
||||||
open FIX, ">$fixfile";
|
$first = 0;
|
||||||
print FIX $fixexpr;
|
print FIX $fixexpr;
|
||||||
close FIX;
|
|
||||||
|
|
||||||
# Instantiate a Nix expression from the Fix expression.
|
push @ids, $id;
|
||||||
my $nid = `fix $fixfile`;
|
|
||||||
$? and die "instantiating Nix archive expression";
|
|
||||||
chomp $nid;
|
|
||||||
die unless $nid =~ /^([0-9a-z]{32})$/;
|
|
||||||
|
|
||||||
push @subs, $id;
|
|
||||||
push @subs, $nid;
|
|
||||||
|
|
||||||
# Does the name encode a successor relation?
|
# Does the name encode a successor relation?
|
||||||
if (defined $fsid) {
|
if (defined $fsid) {
|
||||||
print "NORMAL $fsid -> $id\n";
|
|
||||||
push @sucs, $fsid;
|
push @sucs, $fsid;
|
||||||
push @sucs, $id;
|
push @sucs, $id;
|
||||||
}
|
}
|
||||||
|
@ -84,8 +81,29 @@ while (<CONFFILE>) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
print FIX "]";
|
||||||
|
close FIX;
|
||||||
|
|
||||||
|
# Instantiate Nix expressions from the Fix expressions we created above.
|
||||||
|
print STDERR "running fix...\n";
|
||||||
|
open NIDS, "fix $fixfile |" or die "cannot run fix";
|
||||||
|
my $i = 0;
|
||||||
|
while (<NIDS>) {
|
||||||
|
chomp;
|
||||||
|
die unless /^([0-9a-z]{32})$/;
|
||||||
|
$nid = $1;
|
||||||
|
die unless ($i < scalar @ids);
|
||||||
|
$id = $ids[$i++];
|
||||||
|
push @subs, $id;
|
||||||
|
push @subs, $nid;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Register all substitutes.
|
||||||
|
print STDERR "registering substitutes...\n";
|
||||||
system "nix --substitute @subs";
|
system "nix --substitute @subs";
|
||||||
if ($?) { die "`nix --substitute' failed"; }
|
if ($?) { die "`nix --substitute' failed"; }
|
||||||
|
|
||||||
|
# Register all successors.
|
||||||
|
print STDERR "registering successors...\n";
|
||||||
system "nix --successor @sucs";
|
system "nix --successor @sucs";
|
||||||
if ($?) { die "`nix --successor' failed"; }
|
if ($?) { die "`nix --successor' failed"; }
|
||||||
|
|
Loading…
Reference in a new issue