nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at devShellTools-shell 42 lines 920 B view raw
1{ 2 gzip, 3 runCommand, 4 compressDrv, 5}: 6let 7 example = runCommand "sample-drv" { } '' 8 mkdir $out 9 echo 42 > $out/1.txt 10 echo 43 > $out/1.md 11 touch $out/2.png 12 ''; 13 drv = compressDrv example { 14 formats = [ "txt" ]; 15 compressors.gz = "${gzip}/bin/gzip --force --keep --fast {}"; 16 }; 17 wrapped = compressDrv drv { 18 formats = [ "md" ]; 19 compressors.gz = "${gzip}/bin/gzip --force --keep --fast {}"; 20 }; 21in 22runCommand "test-compressDrv" { } '' 23 set -ex 24 25 ls -l ${drv} 26 test -h ${drv}/1.txt 27 test -f ${drv}/1.txt.gz 28 cmp ${drv}/1.txt <(${gzip}/bin/zcat ${drv}/1.txt.gz) 29 30 test -h ${drv}/2.png 31 test ! -a ${drv}/2.png.gz 32 33 # compressDrv always points to the final file, no matter how many times 34 # it's been wrapped 35 cmp <(readlink -e ${drv}/1.txt) <(readlink -e ${wrapped}/1.txt) 36 37 test -f ${wrapped}/1.txt.gz 38 test -f ${wrapped}/1.md.gz 39 test ! -f ${drv}/1.md.gz 40 41 mkdir $out 42''