diff --git a/scripts/nix-push.in b/scripts/nix-push.in index 10efc48be1..bb5e6da134 100644 --- a/scripts/nix-push.in +++ b/scripts/nix-push.in @@ -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,30 +55,41 @@ 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; - 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})$/; - - # Realise the Nix expression. - system "nix --install $nid"; - 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"; } } +print FIX "]"; +close FIX; + +# Instantiate a Nix expression from the Fix expression. +my @nids; +print STDERR "running fix...\n"; +open NIDS, "fix $fixfile |" or die "cannot run fix"; +while () { + chomp; + die unless /^([0-9a-z]{32})$/; + push @nids, $1; +} + + +# Realise the Nix expression. +my @pushlist; +print STDERR "creating archives...\n"; +system "nix --install @nids > /dev/null"; +if ($?) { die "`nix --install' failed"; } + +open NIDS, "nix --query --list @nids |" or die "cannot run nix"; +while () { + chomp; + die unless (/^\//); + print "$_\n"; + push @pushlist, "$_/*"; +} + # Push the prebuilts to the server. !!! FIXME if (scalar @pushlist > 0) { system "rsync -av -e ssh @pushlist eelco\@losser.st-lab.cs.uu.nl:/home/eelco/public_html/nix-dist/";