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 {
packages = [
pkgs.rage

View File

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

View File

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

View File

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