config/pkgs/gamja.nix

66 lines
1.6 KiB
Nix
Raw Normal View History

2024-02-12 15:10:20 +02:00
{
lib,
2024-02-12 22:46:27 +02:00
stdenvNoCC,
2024-02-12 15:10:20 +02:00
fetchFromSourcehut,
buildNpmPackage,
2024-02-12 16:19:46 +02:00
runCommand,
2024-02-12 15:10:20 +02:00
writeText,
2024-02-12 16:19:46 +02:00
brotli,
zopfli,
xorg,
2024-02-12 22:46:27 +02:00
# https://git.sr.ht/~emersion/gamja/tree/master/doc/config-file.md
2024-02-12 15:10:20 +02:00
gamjaConfig ? null,
2024-02-12 22:46:27 +02:00
}: let
2024-02-12 15:10:20 +02:00
version = "1.0.0-beta.9";
2024-02-13 08:54:50 +02:00
pkg = buildNpmPackage {
2024-02-12 22:46:27 +02:00
pname = "gamja";
inherit version;
2024-02-12 15:10:20 +02:00
2024-02-12 22:46:27 +02:00
src = fetchFromSourcehut {
owner = "~emersion";
repo = "gamja";
rev = "v${version}";
hash = "sha256-09rCj9oMzldRrxMGH4rUnQ6wugfhfmJP3rHET5b+NC8=";
};
2024-02-12 15:10:20 +02:00
2024-02-12 22:46:27 +02:00
npmDepsHash = "sha256-LxShwZacCctKAfMNCUMyrSaI1hIVN80Wseq/d8WITkc=";
2024-02-12 15:10:20 +02:00
2024-02-12 22:46:27 +02:00
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 = ".";
2024-02-12 15:10:20 +02:00
2024-02-12 22:46:27 +02:00
installPhase = ''
runHook preInstall
mv gamja-${version} $out
runHook postInstall
'';
2024-02-12 15:10:20 +02:00
2024-02-12 22:46:27 +02:00
passthru = {
data-compressed = runCommand "gamja-compressed" {} ''
2024-02-12 16:19:46 +02:00
mkdir $out
2024-02-12 22:46:27 +02:00
${xorg.lndir}/bin/lndir ${pkg}/ $out/
2024-02-12 16:19:46 +02:00
find $out \
2024-02-13 08:58:45 +02:00
-regextype posix-extended \
-iregex '.*\.(css|js|json|map|webmanifest|html)' | \
2024-02-12 16:19:46 +02:00
tee >(xargs -n1 -P''$(nproc) ${zopfli}/bin/zopfli) | \
2024-02-13 08:58:45 +02:00
xargs -n1 -P''$(nproc) ${brotli}/bin/brotli
2024-02-12 16:19:46 +02:00
'';
2024-02-12 22:46:27 +02:00
};
2024-02-12 16:19:46 +02:00
2024-02-12 22:46:27 +02:00
meta = with lib; {
description = "A simple IRC web client";
homepage = "https://git.sr.ht/~emersion/gamja";
license = licenses.agpl3Only;
maintainers = with maintainers; [motiejus];
};
}