compress: accept args too

This commit is contained in:
Motiejus Jakštys 2024-02-13 21:01:38 +02:00
parent db07a9d5ba
commit 6f6a4c9855
4 changed files with 13 additions and 13 deletions

View File

@ -323,8 +323,6 @@
}; };
}; };
packages.gamja = pkgs.compressAll pkgs.gamja;
devShells.default = pkgs.mkShellNoCC { devShells.default = pkgs.mkShellNoCC {
packages = [ packages = [
pkgs.rage pkgs.rage

View File

@ -299,20 +299,20 @@
redir https://jakstys.lt redir https://jakstys.lt
''; '';
"irc.jakstys.lt".extraConfig = let "irc.jakstys.lt".extraConfig = let
gamja = pkgs.gamja.override { gamja = pkgs.compressAll (pkgs.gamja.override {
gamjaConfig = { gamjaConfig = {
server = { server = {
url = "irc.jakstys.lt:6698"; url = "irc.jakstys.lt:6698";
nick = "motiejus"; nick = "motiejus";
}; };
}; };
}; }) {};
in '' in ''
@denied not remote_ip ${myData.subnets.tailscale.cidr} @denied not remote_ip ${myData.subnets.tailscale.cidr}
abort @denied abort @denied
tls {$CREDENTIALS_DIRECTORY}/irc.jakstys.lt-cert.pem {$CREDENTIALS_DIRECTORY}/irc.jakstys.lt-key.pem tls {$CREDENTIALS_DIRECTORY}/irc.jakstys.lt-cert.pem {$CREDENTIALS_DIRECTORY}/irc.jakstys.lt-key.pem
root * ${pkgs.compressAll gamja} root * ${gamja}
file_server browse { file_server browse {
precompressed br gzip precompressed br gzip
} }

View File

@ -78,7 +78,7 @@
route /static/assets/* { route /static/assets/* {
uri strip_prefix /static/assets uri strip_prefix /static/assets
file_server * { file_server * {
root ${pkgs.compressAll pkgs.gitea.data}/public root ${pkgs.compressAll pkgs.gitea.data {}}/public
precompressed br gzip precompressed br gzip
} }
} }

View File

@ -58,14 +58,14 @@ This feature is also available in nginx via `ngx_brotli` and
Inputs: Inputs:
- extensions :: [String] - formats :: [String]
The default list of file extensions to compress. The default list of file extensions to compress.
Default: common formats that compress well. The list may be appended (but Default: common formats that compress well. The list may be appended (but
not reduced) without warning. not reduced) without warning.
- extraExtensions :: [String] - extraFormats :: [String]
Extra extensions to compress in addition to `extensions`. Extra extensions to compress in addition to `extensions`.
@ -98,10 +98,12 @@ Inputs:
brotli, brotli,
xz, xz,
zstd, zstd,
extensions ? ["css" "js" "svg" "ttf" "eot" "txt" "xml" "map" "html" "json" "webmanifest"], }: drv: {
extraExtensions ? [], formats ? ["css" "js" "svg" "ttf" "eot" "txt" "xml" "map" "html" "json" "webmanifest"],
extraFormats ? [],
compressors ? ["gz" "br"], compressors ? ["gz" "br"],
} @ args: drv: let ...
} @ args: let
compressorMap = compressorMap =
{ {
compressor-gz = "${zopfli}/bin/zopfli --keep {}"; compressor-gz = "${zopfli}/bin/zopfli --keep {}";
@ -116,13 +118,13 @@ Inputs:
prog = builtins.getAttr "compressor-${ext}" compressorMap; prog = builtins.getAttr "compressor-${ext}" compressorMap;
in "tee >(xargs -I{} -n1 -P$NIX_BUILD_CORES ${prog})") in "tee >(xargs -I{} -n1 -P$NIX_BUILD_CORES ${prog})")
compressors; compressors;
extensionsVbar = builtins.concatStringsSep "|" (extensions ++ extraExtensions); formatsbar = builtins.concatStringsSep "|" (formats ++ extraFormats);
in in
runCommand "${drv.name}-compressed" {} '' runCommand "${drv.name}-compressed" {} ''
mkdir $out mkdir $out
${xorg.lndir}/bin/lndir ${drv}/ $out/ ${xorg.lndir}/bin/lndir ${drv}/ $out/
find -L $out -type f -regextype posix-extended \ find -L $out -type f -regextype posix-extended \
-iregex '.*\.(${extensionsVbar})' | \ -iregex '.*\.(${formatsbar})' | \
${builtins.concatStringsSep " | \\\n " compressCommands} ${builtins.concatStringsSep " | \\\n " compressCommands}
'' ''