compress-drv-tests
This commit is contained in:
29
pkgs/compress-drv-tests.nix
Normal file
29
pkgs/compress-drv-tests.nix
Normal file
@@ -0,0 +1,29 @@
|
||||
{
|
||||
gzip,
|
||||
callPackage,
|
||||
runCommandNoCC,
|
||||
}: let
|
||||
compressDrv = (callPackage ./compress-drv.nix {}).compressDrv;
|
||||
|
||||
example = runCommandNoCC "sample-drv" {} ''
|
||||
mkdir $out
|
||||
echo 1 > $out/1.txt
|
||||
touch $out/2.png
|
||||
'';
|
||||
drv = compressDrv example {
|
||||
formats = ["txt"];
|
||||
compressors = ["gz"];
|
||||
compressor-gz = "${gzip}/bin/gzip --force --keep --fast {}";
|
||||
};
|
||||
in
|
||||
runCommandNoCC "test-compressDrv" {} ''
|
||||
set -ex
|
||||
find ${drv}
|
||||
test -h ${drv}/1.txt
|
||||
test -f ${drv}/1.txt.gz
|
||||
cmp ${drv}/1.txt <(${gzip}/bin/zcat ${drv}/1.txt.gz)
|
||||
|
||||
test -h ${drv}/2.png
|
||||
test ! -a ${drv}/2.png.gz
|
||||
mkdir $out
|
||||
''
|
||||
@@ -26,6 +26,7 @@
|
||||
find -L $out -type f -regextype posix-extended \
|
||||
-iregex '.*\.(${formatsbar})' | \
|
||||
${builtins.concatStringsSep " | \\\n " compressCommands}
|
||||
find $out/
|
||||
'';
|
||||
in {
|
||||
/*
|
||||
@@ -46,7 +47,7 @@ in {
|
||||
|
||||
Example: ["gz" "zstd"]
|
||||
|
||||
- compressor-<COMPRESSOR> :: String
|
||||
- compressor-<EXTENSION> :: String
|
||||
|
||||
Map a desired extension (e.g. `gz`) to a compress program.
|
||||
|
||||
@@ -55,14 +56,19 @@ in {
|
||||
|
||||
xargs -I{} -n1 ${prog}
|
||||
|
||||
Example:
|
||||
Compressor must:
|
||||
- read symlinks (thus --force is needed to gzip, zstd, xz).
|
||||
- keep the original file in place (--keep).
|
||||
|
||||
compressor-xz = "${xz}/bin/xz --keep {}";
|
||||
Example compressor:
|
||||
|
||||
compressor-xz = "${xz}/bin/xz --force --keep {}";
|
||||
|
||||
See compressDrvWeb, which is a wrapper on top of compressDrv, for broader
|
||||
use examples.
|
||||
*/
|
||||
inherit (compressDrv);
|
||||
|
||||
compressDrv = compressDrv;
|
||||
|
||||
/*
|
||||
compressDrvWeb compresses a derivation for "web server" usage.
|
||||
|
||||
Reference in New Issue
Block a user