gamja: compress

This commit is contained in:
Motiejus Jakštys 2024-02-12 16:19:46 +02:00
parent e0cb84ad36
commit d0328b363c
3 changed files with 27 additions and 1 deletions

View File

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

View File

@ -303,7 +303,7 @@
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.gamja} root * ${pkgs.gamja.passthru.data-compressed}
file_server browse { file_server browse {
precompressed br gzip precompressed br gzip
} }

View File

@ -1,9 +1,14 @@
{ {
lib, lib,
gamja,
fetchFromSourcehut, fetchFromSourcehut,
buildNpmPackage, buildNpmPackage,
runCommand,
python3, python3,
writeText, writeText,
brotli,
zopfli,
xorg,
# optional configuration attrSet, see https://git.sr.ht/~emersion/gamja#configuration-file for possible values # optional configuration attrSet, see https://git.sr.ht/~emersion/gamja#configuration-file for possible values
gamjaConfig ? null, gamjaConfig ? null,
}: }:
@ -32,6 +37,25 @@ buildNpmPackage rec {
runHook postInstall runHook postInstall
''; '';
passthru = {
data-compressed =
runCommand "soju-data-compressed" {
nativeBuildInputs = [brotli zopfli xorg.lndir];
} ''
mkdir $out
lndir ${gamja}/ $out/
find $out \
-name '*.css' -or \
-name '*.js' -or \
-name '*.map' -or \
-name '*.webmanifest' -or \
-name '*.html' | \
tee >(xargs -n1 -P''$(nproc) ${zopfli}/bin/zopfli) | \
xargs -n1 -P''$(nproc) ${brotli}/bin/brotli
'';
};
meta = with lib; { meta = with lib; {
description = "A simple IRC web client"; description = "A simple IRC web client";
homepage = "https://git.sr.ht/~emersion/gamja"; homepage = "https://git.sr.ht/~emersion/gamja";