about summary refs log tree commit diff
path: root/corepkgs/nar.nix
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2012-08-27T18·34-0400
committerEelco Dolstra <eelco.dolstra@logicblox.com>2012-08-27T18·34-0400
commit15e1b2c223494ecb5efefc3ea0e3b926a6b1d7dc (patch)
tree49c0c914a6d3d02f54150bfaba3731aa9b98d720 /corepkgs/nar.nix
parenta9e6752bbd888ab8fbc1cda6e4d539b2858c4cef (diff)
parent9e2fc6951ca049b15149a2c4b75d2f5bff7f07e1 (diff)
Merge branch 'no-manifests'
Diffstat (limited to 'corepkgs/nar.nix')
-rw-r--r--corepkgs/nar.nix21
1 files changed, 15 insertions, 6 deletions
diff --git a/corepkgs/nar.nix b/corepkgs/nar.nix
index 4747dc31def2..fc9687af776c 100644
--- a/corepkgs/nar.nix
+++ b/corepkgs/nar.nix
@@ -6,28 +6,37 @@ let
     ''
       export PATH=${nixBinDir}:${coreutils}
 
+      if [ $compressionType = "xz" ]; then
+        ext=xz
+        compressor="${xz} -9"
+      else
+        ext=bz2
+        compressor="${bzip2}"
+      fi
+
       echo "packing ‘$storePath’..."
       mkdir $out
-      dst=$out/tmp.nar.bz2
+      dst=$out/tmp.nar.$ext
 
       set -o pipefail
-      nix-store --dump "$storePath" | ${bzip2} > $dst
+      nix-store --dump "$storePath" | $compressor > $dst
 
-      nix-hash --flat --type $hashAlgo --base32 $dst > $out/narbz2-hash
+      hash=$(nix-hash --flat --type $hashAlgo --base32 $dst)
+      echo -n $hash > $out/nar-compressed-hash
 
-      mv $out/tmp.nar.bz2 $out/$(cat $out/narbz2-hash).nar.bz2
+      mv $dst $out/$hash.nar.$ext
     '';
 
 in
 
-{ storePath, hashAlgo }:
+{ storePath, hashAlgo, compressionType }:
 
 derivation {
   name = "nar";
   system = builtins.currentSystem;
   builder = shell;
   args = [ "-e" builder ];
-  inherit storePath hashAlgo;
+  inherit storePath hashAlgo compressionType;
 
   # Don't build in a chroot because Nix's dependencies may not be there.
   __noChroot = true;