about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2003-07-21T21·34+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2003-07-21T21·34+0000
commitc7bdb76fe461e2335caeea01c16b39a2784fa506 (patch)
tree9202fd4f800c63ce16298bce068b654d77ed126c
parentd5ee6f8700c7225a4ce34f6d92aae0d57bee3355 (diff)
* Syntax fixes.
* When pushing, put the hash in the file name so that the 
  client can verify (proof-carrying file names?).

-rw-r--r--corepkgs/nar/nar.fix4
-rw-r--r--corepkgs/nar/nar.sh.in7
-rw-r--r--scripts/nix-push.in30
-rwxr-xr-xscripts/nix-switch.in8
4 files changed, 32 insertions, 17 deletions
diff --git a/corepkgs/nar/nar.fix b/corepkgs/nar/nar.fix
index 3db6a48a0838..429e7b5497a3 100644
--- a/corepkgs/nar/nar.fix
+++ b/corepkgs/nar/nar.fix
@@ -1,6 +1,6 @@
-Function(["path", "name"],
+Function(["path"],
   Package(
-    [ ("name", Var("name"))
+    [ ("name", "nar")
     , ("build", Relative("nar/nar.sh"))
     , ("path", Var("path"))
     ]
diff --git a/corepkgs/nar/nar.sh.in b/corepkgs/nar/nar.sh.in
index bffbbaf5e1df..d21668553777 100644
--- a/corepkgs/nar/nar.sh.in
+++ b/corepkgs/nar/nar.sh.in
@@ -1,5 +1,10 @@
 #! /bin/sh
 
 echo "packing $path into $out..."
-@bindir@/nix --dump --file "$path" | bzip2 > $out || exit 1
+mkdir $out || exit 1
+tmp=$out/tmp
+@bindir@/nix --dump --path "$path" | bzip2 > $out/tmp || exit 1
 
+md5=$(md5sum -b $tmp | cut -c1-32)
+if test $? != 0; then exit 1; fi
+mv $out/tmp $out/$md5-`basename $path`.nar.bz2 || exit 1
diff --git a/scripts/nix-push.in b/scripts/nix-push.in
index bb25019e8d35..4a6426fe0aed 100644
--- a/scripts/nix-push.in
+++ b/scripts/nix-push.in
@@ -8,17 +8,28 @@ foreach my $id (@ARGV) {
 
     # Get all paths referenced by the normalisation of the given 
     # fstate expression.
-    system "nix -ih $id";
-    if ($?) { die "`nix -ih' failed"; }
+    system "nix --install $id";
+    if ($?) { die "`nix --install' failed"; }
+
     my @paths;
-    open PATHS, "nix -qrh $id 2> /dev/null |" or die "nix -qrh";
+
+    open PATHS, "nix --query --refs $id 2> /dev/null |" or die "nix -qr";
     while (<PATHS>) {
         chomp;
-        next unless /^\//;
+        die "bad: $_" unless /^\//;
         push @paths, $_;
     }
     close PATHS;
 
+    # Also add all normal forms that are contained in these paths.
+    open PATHS, "nix --query --generators --path @paths |" or die "nix -qg";
+    while (<PATHS>) {
+	chomp;
+        die "bad: $_" unless /^\//;
+	push @paths, $_;
+    }
+    close PATHS;
+
     # For each path, create a Fix expression that turns the path into
     # a Nix archive.
     foreach my $path (@paths) {
@@ -38,7 +49,6 @@ foreach my $id (@ARGV) {
         my $fixexpr = 
           "App(IncludeFix(\"nar/nar.fix\"), " .
           "[ (\"path\", Slice([\"$pathid\"], [(\"$path\", \"$pathid\", [])]))" .
-          ", (\"name\", \"$name\")" .
           "])";
 	
         my $fixfile = "/tmp/nix-push-tmp.fix";
@@ -53,13 +63,13 @@ foreach my $id (@ARGV) {
         die unless $nid =~ /^([0-9a-z]{32})$/;
 
         # Realise the Nix expression.
-	system "nix -ih $nid";
-	if ($?) { die "`nix -ih' failed"; }
-        my $npath = `nix -qph $nid 2> /dev/null`;
-        $? and die "creating Nix archive";
+	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;
+        push @pushlist, "$npath/*";
 
         print "$path -> $npath\n";
     }
diff --git a/scripts/nix-switch.in b/scripts/nix-switch.in
index 2ccb6b4e5786..ddaca4e227ad 100755
--- a/scripts/nix-switch.in
+++ b/scripts/nix-switch.in
@@ -15,11 +15,11 @@ $hash || die "no package hash specified";
 my $linkdir = "@localstatedir@/nix/links";
 
 # Build the specified package, and all its dependencies.
-system "nix -ih $hash";
-if ($?) { die "`nix -ih' failed"; }
+system "nix --install $hash";
+if ($?) { die "`nix --install' failed"; }
 
-my $pkgdir = `nix -qph $hash`;
-if ($?) { die "`nix -qph' failed"; }
+my $pkgdir = `nix --query --list $hash`;
+if ($?) { die "`nix --query --list' failed"; }
 chomp $pkgdir;
 
 # Figure out a generation number.