From 48cea0d01ef48733ab38a73a20611f63aeb1b5cc Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 3 Jan 2012 00:16:29 +0000 Subject: * Refactoring: Get rid of a few subdirectories in corepkgs/, and some other simplifications. * Use to locate the corepkgs. This allows them to be overriden through $NIX_PATH. * Use bash's pipefail option in the NAR builder so that we don't need to create a temporary file. --- corepkgs/nar.nix | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 corepkgs/nar.nix (limited to 'corepkgs/nar.nix') diff --git a/corepkgs/nar.nix b/corepkgs/nar.nix new file mode 100644 index 000000000000..70a4af2f9ddb --- /dev/null +++ b/corepkgs/nar.nix @@ -0,0 +1,30 @@ +with import ; + +let + + builder = builtins.toFile "nar.sh" + '' + export PATH=${nixBinDir}:${coreutils} + + echo "packing ‘$storePath’..." + mkdir $out + dst=$out/tmp.nar.bz2 + + set -o pipefail + nix-store --dump "$storePath" | ${bzip2} > $dst + + nix-hash --flat --type $hashAlgo --base32 $dst > $out/narbz2-hash + + mv $out/tmp.nar.bz2 $out/$(cat $out/narbz2-hash).nar.bz2 + ''; + +in + +{ system, storePath, hashAlgo }: + +derivation { + name = "nar"; + builder = shell; + args = [ "-e" builder ]; + inherit system storePath hashAlgo; +} -- cgit 1.4.1