diff --git a/pkgs/build-support/compress-drv/default.nix b/pkgs/build-support/compress-drv/default.nix index 0773ab9e0554..f916e9e89a08 100644 --- a/pkgs/build-support/compress-drv/default.nix +++ b/pkgs/build-support/compress-drv/default.nix @@ -9,6 +9,12 @@ : List of file extensions to compress. Example: `["txt" "svg" "xml"]`. + `extraFindOperands` (String) + + : Extra command line parameters to pass to the find command. + This can be used to exclude certain files. + For example: `-not -iregex ".*(\/apps\/.*\/l10n\/).*"` + `compressors` ( { ${fileExtension} :: String }) : Map a desired extension (e.g. `gz`) to a compress program. @@ -47,7 +53,11 @@ ::: */ drv: -{ formats, compressors }: +{ + formats, + compressors, + extraFindOperands ? "", +}: let validProg = ext: prog: @@ -61,10 +71,10 @@ let ext: prog: assert validProg ext prog; '' - find -L $out -type f -regextype posix-extended -iregex '.*\.(${formatsPipe})' -print0 \ + find -L $out -type f -regextype posix-extended -iregex '.*\.(${formatsPipe})' ${extraFindOperands} -print0 \ | xargs -0 -P$NIX_BUILD_CORES -I{} ${prog} ''; - formatsPipe = builtins.concatStringsSep "|" formats; + formatsPipe = lib.concatStringsSep "|" formats; in runCommand "${drv.name}-compressed" { } '' mkdir $out diff --git a/pkgs/build-support/compress-drv/web.nix b/pkgs/build-support/compress-drv/web.nix index 462cd0811bb4..17deb1c0e3bd 100644 --- a/pkgs/build-support/compress-drv/web.nix +++ b/pkgs/build-support/compress-drv/web.nix @@ -19,6 +19,10 @@ Defaults to common formats that compress well. + `extraFindOperands` (String) + + : See compressDrv for details. + `extraFormats` ([ String ]) : Extra extensions to compress in addition to `formats`. @@ -132,8 +136,10 @@ drv: # https://github.com/NixOS/nixpkgs/pull/332752#issuecomment-2275110390 zstd = "${lib.getExe zstd} --force --keep --quiet -19 {}"; }, + extraFindOperands ? "", }: compressDrv drv { formats = formats ++ extraFormats; compressors = compressors; + inherit extraFindOperands; }