compress-drv-tests
This commit is contained in:
parent
b6724ef10e
commit
4a74dc2ac1
@ -310,6 +310,11 @@
|
|||||||
statix.enable = true;
|
statix.enable = true;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
compress-drv-tests = let
|
||||||
|
pkgs = import nixpkgs {inherit system;};
|
||||||
|
in
|
||||||
|
pkgs.callPackage ./pkgs/compress-drv-tests.nix {};
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
deploy-rs.lib;
|
deploy-rs.lib;
|
||||||
|
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 \
|
find -L $out -type f -regextype posix-extended \
|
||||||
-iregex '.*\.(${formatsbar})' | \
|
-iregex '.*\.(${formatsbar})' | \
|
||||||
${builtins.concatStringsSep " | \\\n " compressCommands}
|
${builtins.concatStringsSep " | \\\n " compressCommands}
|
||||||
|
find $out/
|
||||||
'';
|
'';
|
||||||
in {
|
in {
|
||||||
/*
|
/*
|
||||||
@ -46,7 +47,7 @@ in {
|
|||||||
|
|
||||||
Example: ["gz" "zstd"]
|
Example: ["gz" "zstd"]
|
||||||
|
|
||||||
- compressor-<COMPRESSOR> :: String
|
- compressor-<EXTENSION> :: String
|
||||||
|
|
||||||
Map a desired extension (e.g. `gz`) to a compress program.
|
Map a desired extension (e.g. `gz`) to a compress program.
|
||||||
|
|
||||||
@ -55,14 +56,19 @@ in {
|
|||||||
|
|
||||||
xargs -I{} -n1 ${prog}
|
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
|
See compressDrvWeb, which is a wrapper on top of compressDrv, for broader
|
||||||
use examples.
|
use examples.
|
||||||
*/
|
*/
|
||||||
inherit (compressDrv);
|
|
||||||
|
compressDrv = compressDrv;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
compressDrvWeb compresses a derivation for "web server" usage.
|
compressDrvWeb compresses a derivation for "web server" usage.
|
||||||
|
10
statix.toml
10
statix.toml
@ -1 +1,11 @@
|
|||||||
ignore = ['modules/base/boot']
|
ignore = ['modules/base/boot']
|
||||||
|
|
||||||
|
# If the attrset has an optional field, `inherit` will not inherit it:
|
||||||
|
# compressDrvWeb = drv: {
|
||||||
|
# compressors ? ["gz" "br"],
|
||||||
|
# ...
|
||||||
|
# } @ args:
|
||||||
|
# compressDrv drv {
|
||||||
|
# inherit (compressors) <<- function 'compressDrv' called without required argument 'compressors'
|
||||||
|
# }
|
||||||
|
disabled = ["manual_inherit", "manual_inherit_from"]
|
||||||
|
Loading…
Reference in New Issue
Block a user