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,
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 = {
boot = {
enable = true;
@ -307,7 +298,16 @@ in {
"www.jakstys.lt".extraConfig = ''
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}
abort @denied
tls {$CREDENTIALS_DIRECTORY}/irc.jakstys.lt-cert.pem {$CREDENTIALS_DIRECTORY}/irc.jakstys.lt-key.pem

View File

@ -1,48 +1,52 @@
{
lib,
gamja,
stdenvNoCC,
fetchFromSourcehut,
buildNpmPackage,
runCommand,
python3,
writeText,
brotli,
zopfli,
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,
}:
buildNpmPackage rec {
pname = "gamja";
}: let
version = "1.0.0-beta.9";
pkg = buildNpmPackage rec {
pname = "gamja";
inherit version;
src = fetchFromSourcehut {
owner = "~emersion";
repo = "gamja";
rev = "v${version}";
hash = "sha256-09rCj9oMzldRrxMGH4rUnQ6wugfhfmJP3rHET5b+NC8=";
src = fetchFromSourcehut {
owner = "~emersion";
repo = "gamja";
rev = "v${version}";
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
nativeBuildInputs = [python3];
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" {
} ''
passthru = {
data-compressed = runCommand "gamja-compressed" {} ''
mkdir $out
${xorg.lndir}/bin/lndir ${gamja}/ $out/
${xorg.lndir}/bin/lndir ${pkg}/ $out/
find $out \
-name '*.css' -or \
@ -54,12 +58,12 @@ buildNpmPackage rec {
tee >(xargs -n1 -P''$(nproc) ${zopfli}/bin/zopfli) | \
xargs -n1 -P''$(nproc) ${brotli}/bin/brotli
'';
};
};
meta = with lib; {
description = "A simple IRC web client";
homepage = "https://git.sr.ht/~emersion/gamja";
license = licenses.agpl3Only;
maintainers = with maintainers; [motiejus];
};
}
meta = with lib; {
description = "A simple IRC web client";
homepage = "https://git.sr.ht/~emersion/gamja";
license = licenses.agpl3Only;
maintainers = with maintainers; [motiejus];
};
}