nix/corepkgs/unpack-channel.nix

40 lines
884 B
Nix
Raw Normal View History

with import <nix/config.nix>;
2012-08-01 20:34:17 +00:00
let
builder = builtins.toFile "unpack-channel.sh"
''
mkdir $out
cd $out
pat="\.xz\$"
if [[ "$src" =~ $pat ]]; then
${xz} -d < $src | ${tar} xf - ${tarFlags}
else
${bzip2} -d < $src | ${tar} xf - ${tarFlags}
fi
2012-08-01 20:34:17 +00:00
mv * $out/$channelName
if [ -n "$binaryCacheURL" ]; then
mkdir $out/binary-caches
echo -n "$binaryCacheURL" > $out/binary-caches/$channelName
fi
2012-08-01 20:34:17 +00:00
'';
in
{ name, channelName, src, binaryCacheURL ? "" }:
derivation {
system = builtins.currentSystem;
builder = shell;
2012-08-01 20:34:17 +00:00
args = [ "-e" builder ];
inherit name channelName src binaryCacheURL;
2012-08-01 20:34:17 +00:00
PATH = "${nixBinDir}:${coreutils}";
2012-08-01 20:34:17 +00:00
# No point in doing this remotely.
preferLocalBuild = true;
# Don't build in a chroot because Nix's dependencies may not be there.
__noChroot = true;
}