* Fix nix-pull.

This commit is contained in:
Eelco Dolstra 2003-11-24 09:25:08 +00:00
parent c9cb1fa21f
commit 496934a99c

View file

@ -18,7 +18,6 @@ my @subs;
my @sucs; my @sucs;
my $fullexpr = "["; my $fullexpr = "[";
my $first = 1;
open CONFFILE, "<$conffile"; open CONFFILE, "<$conffile";
@ -63,20 +62,15 @@ while (<CONFFILE>) {
my $fullurl = "$url/$narname"; my $fullurl = "$url/$narname";
print "$storepath\n"; print "$storepath\n";
# Construct a Fix expression that fetches and unpacks a # Construct a Nix expression that fetches and unpacks a
# Nix archive from the network. # Nix archive from the network.
my $fetch = my $fetch =
"App(IncludeFix(\"fetchurl/fetchurl.fix\"), " . "(import @datadir@/nix/corepkgs/fetchurl) " .
"[(\"url\", \"$fullurl\"), (\"md5\", \"$hash\")])"; "{url = $fullurl; md5 = \"$hash\"; system = \"@host@\"}";
my $fixexpr = my $nixexpr =
"App(IncludeFix(\"nar/unnar.fix\"), " . "((import @datadir@/nix/corepkgs/nar/unnar.nix) " .
"[ (\"nar\", $fetch)" . "{narFile = ($fetch); outPath = \"$storepath\"; system = \"@host@\"}) ";
", (\"outPath\", \"$storepath\")" . $fullexpr .= $nixexpr; # !!! O(n^2)?
"])";
if (!$first) { $fullexpr .= "," };
$first = 0;
$fullexpr .= $fixexpr; # !!! O(n^2)?
push @srcpaths, $storepath; push @srcpaths, $storepath;
@ -110,9 +104,9 @@ while (<CONFFILE>) {
$fullexpr .= "]"; $fullexpr .= "]";
# Instantiate Nix expressions from the Fix expressions we created above. # Instantiate store expressions from the Nix expressions we created above.
print STDERR "running fix...\n"; print STDERR "instantiating Nix expression...\n";
my $pid = open2(\*READ, \*WRITE, "fix -") or die "cannot run fix"; my $pid = open2(\*READ, \*WRITE, "nix-instantiate -") or die "cannot run nix-instantiate";
print WRITE $fullexpr; print WRITE $fullexpr;
close WRITE; close WRITE;
@ -128,16 +122,16 @@ while (<READ>) {
} }
waitpid $pid, 0; waitpid $pid, 0;
$? == 0 or die "fix failed"; $? == 0 or die "nix-instantiate failed";
# Register all substitutes. # Register all substitutes.
print STDERR "registering substitutes...\n"; print STDERR "registering substitutes...\n";
system "nix --substitute @subs"; system "nix-store --substitute @subs";
if ($?) { die "`nix --substitute' failed"; } if ($?) { die "`nix-store --substitute' failed"; }
# Register all successors. # Register all successors.
print STDERR "registering successors...\n"; print STDERR "registering successors...\n";
system "nix --successor @sucs"; system "nix-store --successor @sucs";
if ($?) { die "`nix --successor' failed"; } if ($?) { die "`nix-store --successor' failed"; }