2024-02-24 19:43:19 +02:00
|
|
|
{
|
|
|
|
gzip,
|
2024-07-06 22:45:14 +03:00
|
|
|
runCommand,
|
|
|
|
compressDrv,
|
2024-07-29 15:39:54 +03:00
|
|
|
}:
|
|
|
|
let
|
|
|
|
example = runCommand "sample-drv" { } ''
|
2024-02-24 19:43:19 +02:00
|
|
|
mkdir $out
|
2024-07-06 22:45:14 +03:00
|
|
|
echo 42 > $out/1.txt
|
2024-07-29 15:19:49 +03:00
|
|
|
echo 43 > $out/1.md
|
2024-02-24 19:43:19 +02:00
|
|
|
touch $out/2.png
|
|
|
|
'';
|
|
|
|
drv = compressDrv example {
|
2024-07-29 15:39:54 +03:00
|
|
|
formats = [ "txt" ];
|
2024-07-29 15:19:49 +03:00
|
|
|
compressors.gz = "${gzip}/bin/gzip --force --keep --fast {}";
|
|
|
|
};
|
|
|
|
wrapped = compressDrv drv {
|
2024-07-29 15:39:54 +03:00
|
|
|
formats = [ "md" ];
|
2024-07-29 15:19:49 +03:00
|
|
|
compressors.gz = "${gzip}/bin/gzip --force --keep --fast {}";
|
2024-02-24 19:43:19 +02:00
|
|
|
};
|
|
|
|
in
|
2024-07-29 15:39:54 +03:00
|
|
|
runCommand "test-compressDrv" { } ''
|
|
|
|
set -ex
|
2024-07-29 15:19:49 +03:00
|
|
|
|
2024-07-29 15:39:54 +03:00
|
|
|
ls -l ${drv}
|
|
|
|
test -h ${drv}/1.txt
|
|
|
|
test -f ${drv}/1.txt.gz
|
|
|
|
cmp ${drv}/1.txt <(${gzip}/bin/zcat ${drv}/1.txt.gz)
|
2024-02-24 19:43:19 +02:00
|
|
|
|
2024-07-29 15:39:54 +03:00
|
|
|
test -h ${drv}/2.png
|
|
|
|
test ! -a ${drv}/2.png.gz
|
2024-07-29 15:19:49 +03:00
|
|
|
|
2024-07-29 15:39:54 +03:00
|
|
|
# compressDrv always points to the final file, no matter how many times
|
|
|
|
# it's been wrapped
|
|
|
|
cmp <(readlink -e ${drv}/1.txt) <(readlink -e ${wrapped}/1.txt)
|
2024-07-29 15:19:49 +03:00
|
|
|
|
2024-07-29 15:39:54 +03:00
|
|
|
test -f ${wrapped}/1.txt.gz
|
|
|
|
test -f ${wrapped}/1.md.gz
|
|
|
|
test ! -f ${drv}/1.md.gz
|
2024-07-29 15:19:49 +03:00
|
|
|
|
2024-07-29 15:39:54 +03:00
|
|
|
mkdir $out
|
|
|
|
''
|