diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2003-07-10 13:41:28 +0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2003-07-10 13:41:28 +0000 |
commit | d072485d2895d01dbbab1d899418726e3349343f (patch) | |
tree | 237c23cdb613d363e9205f89d51cac8433cf3b85 /scripts | |
parent | 5d4b90b689b09965be39c69aceddaf0b165598d0 (diff) |
* Get `nix-push' working again. It now uses Nix/Fix to create Nix
archives (using the package in corepkgs/nar).
* queryPathByHash -> expandHash, and it takes an argument specifying
the target path (which may be empty).
* Install the core Fix packages in $prefix/share/fix. TODO: bootstrap
Nix and install Nix as a Fix package.
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/Makefile.am | 2 | ||||
-rw-r--r-- | scripts/nix-pull | 2 | ||||
-rw-r--r-- | scripts/nix-push | 60 |
3 files changed, 63 insertions, 1 deletions
diff --git a/scripts/Makefile.am b/scripts/Makefile.am index cf70f1574..e4602f2a1 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -1,5 +1,5 @@ bin_SCRIPTS = nix-switch nix-collect-garbage \ - nix-pull-prebuilts nix-push-prebuilts + nix-pull nix-push install-exec-local: $(INSTALL) -d $(sysconfdir)/profile.d diff --git a/scripts/nix-pull b/scripts/nix-pull new file mode 100644 index 000000000..0b09c8e00 --- /dev/null +++ b/scripts/nix-pull @@ -0,0 +1,2 @@ +#! /usr/bin/perl -w + diff --git a/scripts/nix-push b/scripts/nix-push new file mode 100644 index 000000000..14b7e2834 --- /dev/null +++ b/scripts/nix-push @@ -0,0 +1,60 @@ +#! /usr/bin/perl -w + +my @pushlist; + +foreach my $hash (@ARGV) { + + die unless $hash =~ /^([0-9a-z]{32})$/; + + # Get all paths referenced by the normalisation of the given + # fstate expression. + my @paths; + open PATHS, "nix -qrh $hash 2> /dev/null |" or die "nix -qrh"; + while (<PATHS>) { + chomp; + next unless /^\//; + push @paths, $_; + } + close PATHS; + + # For each path, create a Fix expression that turns the path into + # a Nix archive. + foreach my $path (@paths) { + + # Hash the path. + my $phash = `nix-hash $path`; + $? and die "nix-hash"; + chomp $phash; + die unless $phash =~ /^([0-9a-z]{32})$/; + + # Construct a Fix expression that creates a Nar archive. + my $fixexpr = + "App(IncludeFix(\"nar/nar.fix\"), " . + "[ (\"path\", Path(\"$path\", Hash(\"$phash\"), [Include(\"$hash\")]))" . + ", (\"name\", \"$phash.nar\")" . + "])"; + + my $fixfile = "/tmp/nix-push-tmp.fix"; + open FIX, ">$fixfile"; + print FIX $fixexpr; + close FIX; + + # Instantiate a Nix expression from the Fix expression. + my $nhash = `fix $fixfile`; + $? and die "instantiating Nix archive expression"; + chomp $nhash; + die unless $nhash =~ /^([0-9a-z]{32})$/; + + # Realise the Nix expression. + my $npath = `nix -qph $nhash 2> /dev/null`; + $? and die "creating Nix archive"; + chomp $npath; + + push @pushlist, $npath; + + print "$path -> $npath\n"; + } +} + +# Push the prebuilts to the server. !!! FIXME +system "rsync -av -e ssh @pushlist eelco\@losser.st-lab.cs.uu.nl:/home/eelco/public_html/nix-dist/"; |