about summary refs log tree commit diff
path: root/corepkgs
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2012-07-01T22·46-0400
committerEelco Dolstra <eelco.dolstra@logicblox.com>2012-07-01T22·46-0400
commitf4190c38bac1efdbfec9b1ff9c524808d23fe1cc (patch)
tree2cd3282069ec9d3a5edbb251ab344a293dd4b0ec /corepkgs
parent000132cbd1624a681a8114a117de07a56a7eed4e (diff)
Allow both bzip2 and xz compression
Diffstat (limited to 'corepkgs')
-rw-r--r--corepkgs/nar.nix18
1 files changed, 13 insertions, 5 deletions
diff --git a/corepkgs/nar.nix b/corepkgs/nar.nix
index c5155dcc91..cf8851d509 100644
--- a/corepkgs/nar.nix
+++ b/corepkgs/nar.nix
@@ -6,29 +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.xz
+      dst=$out/tmp.nar.$ext
 
       set -o pipefail
-      nix-store --dump "$storePath" | ${xz} -9 > $dst
+      nix-store --dump "$storePath" | $compressor -9 > $dst
 
       hash=$(nix-hash --flat --type $hashAlgo --base32 $dst)
       echo -n $hash > $out/nar-compressed-hash
 
-      mv $dst $out/$hash.nar.xz
+      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;