From f4190c38bac1efdbfec9b1ff9c524808d23fe1cc Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Sun, 1 Jul 2012 18:46:38 -0400 Subject: Allow both bzip2 and xz compression --- corepkgs/nar.nix | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'corepkgs/nar.nix') diff --git a/corepkgs/nar.nix b/corepkgs/nar.nix index c5155dcc917c..cf8851d50978 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; -- cgit 1.4.1