gamja: pack properly

This commit is contained in:
Motiejus Jakštys 2024-02-12 22:46:27 +02:00
parent dac9650b65
commit b9c73de9ce
2 changed files with 52 additions and 48 deletions

View File

@ -4,16 +4,7 @@
pkgs, pkgs,
myData, myData,
... ...
}: let }: {
# TODO: this doesn't get added to the compressed version
gamja = pkgs.gamja.override {
gamjaConfig = {
server = {
url = "irc.jakstys.lt:6698";
};
};
};
in {
zfs-root = { zfs-root = {
boot = { boot = {
enable = true; enable = true;
@ -307,7 +298,16 @@ in {
"www.jakstys.lt".extraConfig = '' "www.jakstys.lt".extraConfig = ''
redir https://jakstys.lt redir https://jakstys.lt
''; '';
"irc.jakstys.lt".extraConfig = '' "irc.jakstys.lt".extraConfig = let
gamja = pkgs.gamja.override {
gamjaConfig = {
server = {
url = "irc.jakstys.lt:6698";
nick = "motiejus";
};
};
};
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

View File

@ -1,48 +1,52 @@
{ {
lib, lib,
gamja, stdenvNoCC,
fetchFromSourcehut, fetchFromSourcehut,
buildNpmPackage, buildNpmPackage,
runCommand, runCommand,
python3,
writeText, writeText,
brotli, brotli,
zopfli, zopfli,
xorg, xorg,
# optional configuration attrSet, see https://git.sr.ht/~emersion/gamja#configuration-file for possible values # https://git.sr.ht/~emersion/gamja/tree/master/doc/config-file.md
gamjaConfig ? null, gamjaConfig ? null,
}: }: let
buildNpmPackage rec {
pname = "gamja";
version = "1.0.0-beta.9"; version = "1.0.0-beta.9";
pkg = buildNpmPackage rec {
pname = "gamja";
inherit version;
src = fetchFromSourcehut { src = fetchFromSourcehut {
owner = "~emersion"; owner = "~emersion";
repo = "gamja"; repo = "gamja";
rev = "v${version}"; rev = "v${version}";
hash = "sha256-09rCj9oMzldRrxMGH4rUnQ6wugfhfmJP3rHET5b+NC8="; hash = "sha256-09rCj9oMzldRrxMGH4rUnQ6wugfhfmJP3rHET5b+NC8=";
};
npmDepsHash = "sha256-LxShwZacCctKAfMNCUMyrSaI1hIVN80Wseq/d8WITkc=";
installPhase = ''
mv dist $out
${lib.optionalString (gamjaConfig != null) "cp ${writeText "gamja-config" (builtins.toJSON gamjaConfig)} $out/config.json"}
'';
}; };
in
stdenvNoCC.mkDerivation {
name = pkg.pname;
inherit (pkg) version;
src = pkg;
sourceRoot = ".";
npmDepsHash = "sha256-LxShwZacCctKAfMNCUMyrSaI1hIVN80Wseq/d8WITkc="; installPhase = ''
runHook preInstall
mv gamja-${version} $out
runHook postInstall
'';
# without this, the aarch64-linux build fails passthru = {
nativeBuildInputs = [python3]; data-compressed = runCommand "gamja-compressed" {} ''
installPhase = ''
runHook preInstall
cp -r dist $out
${lib.optionalString (gamjaConfig != null) "cp ${writeText "gamja-config" (builtins.toJSON gamjaConfig)} $out/config.json"}
runHook postInstall
'';
passthru = {
data-compressed =
runCommand "gamja-compressed" {
} ''
mkdir $out mkdir $out
${xorg.lndir}/bin/lndir ${gamja}/ $out/ ${xorg.lndir}/bin/lndir ${pkg}/ $out/
find $out \ find $out \
-name '*.css' -or \ -name '*.css' -or \
@ -54,12 +58,12 @@ buildNpmPackage rec {
tee >(xargs -n1 -P''$(nproc) ${zopfli}/bin/zopfli) | \ tee >(xargs -n1 -P''$(nproc) ${zopfli}/bin/zopfli) | \
xargs -n1 -P''$(nproc) ${brotli}/bin/brotli 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";
license = licenses.agpl3Only; license = licenses.agpl3Only;
maintainers = with maintainers; [motiejus]; maintainers = with maintainers; [motiejus];
}; };
} }