From 89f79ced4799799ec9d66442dd1ed38aa83e7bd7 Mon Sep 17 00:00:00 2001 From: Fernando Rodrigues Date: Wed, 7 May 2025 10:03:56 -0300 Subject: [PATCH] anubis: split xess derivation into a separate package Unfortunately, because the Xess file needs to be pre-processed and consumed by the final derivation, it couldn't be overridden if it was written in-line. This commit splits it into a separate `anubis-xess` package that can be overridden/overlayed. This also adds myself as a maintainer for Anubis, and removes the `nix-update-script` call, since it was never necessary (because Anubis is hosted on GitHub), stopped working after e049c438a985eca2c9e2c6bf35fd6e3ea8b655ac, and it certainly won't work now. It also corrects the homepage URL. Signed-off-by: Fernando Rodrigues --- pkgs/by-name/an/anubis-xess/package.nix | 35 +++++++++++++++++++++ pkgs/by-name/an/anubis/package.nix | 42 ++++++------------------- 2 files changed, 44 insertions(+), 33 deletions(-) create mode 100644 pkgs/by-name/an/anubis-xess/package.nix diff --git a/pkgs/by-name/an/anubis-xess/package.nix b/pkgs/by-name/an/anubis-xess/package.nix new file mode 100644 index 000000000000..0b6a83cbaf2a --- /dev/null +++ b/pkgs/by-name/an/anubis-xess/package.nix @@ -0,0 +1,35 @@ +{ buildNpmPackage, anubis }: + +buildNpmPackage { + pname = "${anubis.pname}-xess"; + inherit (anubis) version src; + + npmDepsHash = "sha256-hTKTTBmfMGv6I+4YbWrOt6F+qD6ysVYi+DEC1konBFk="; + + buildPhase = '' + runHook preBuild + + npx postcss ./xess/xess.css -o xess.min.css + + runHook postBuild + ''; + + installPhase = '' + runHook preInstall + + install -Dm644 xess.min.css $out/xess.min.css + + runHook postInstall + ''; + + meta = anubis.meta // { + description = "Xess files for Anubis"; + longDescription = '' + This package is consumed by the main `anubis` package to render the final + styling for the bot check page. + + **It is not supposed to be used as a standalone package**, and it exists to + ensure Anubis' styling is override-able by downstreams. + ''; + }; +} diff --git a/pkgs/by-name/an/anubis/package.nix b/pkgs/by-name/an/anubis/package.nix index 1fa977e1131a..39393f755aaa 100644 --- a/pkgs/by-name/an/anubis/package.nix +++ b/pkgs/by-name/an/anubis/package.nix @@ -1,50 +1,28 @@ { lib, buildGoModule, - buildNpmPackage, fetchFromGitHub, - nix-update-script, nixosTests, stdenv, + anubis-xess, + esbuild, brotli, zstd, }: -let + +buildGoModule (finalAttrs: { pname = "anubis"; version = "1.18.0"; src = fetchFromGitHub { owner = "TecharoHQ"; repo = "anubis"; - tag = "v${version}"; + tag = "v${finalAttrs.version}"; hash = "sha256-grtzkNxgShbldjm+lnANbKVhkUrbwseAT1NaBL85mHg="; }; - anubisXess = buildNpmPackage { - inherit version src; - pname = "${pname}-xess"; - - npmDepsHash = "sha256-hTKTTBmfMGv6I+4YbWrOt6F+qD6ysVYi+DEC1konBFk="; - - buildPhase = '' - runHook preBuild - npx postcss ./xess/xess.css -o xess.min.css - runHook postBuild - ''; - - installPhase = '' - runHook preInstall - mkdir -p $out - cp xess.min.css $out - runHook postInstall - ''; - }; -in -buildGoModule (finalAttrs: { - inherit pname version src; - vendorHash = "sha256-EOT/sdVINj9oO1jZHPYB3jQ+XApf9eCUKuMY0tV+vpg="; nativeBuildInputs = [ @@ -72,27 +50,25 @@ buildGoModule (finalAttrs: { ''; preBuild = '' - go generate ./... && ./web/build.sh && cp -r ${anubisXess}/xess.min.css ./xess + go generate ./... && ./web/build.sh && cp -r ${anubis-xess}/xess.min.css ./xess ''; preCheck = '' export DONT_USE_NETWORK=1 ''; - passthru = { - tests = { inherit (nixosTests) anubis; }; - updateScript = nix-update-script { }; - }; + passthru.tests = { inherit (nixosTests) anubis; }; meta = { description = "Weighs the soul of incoming HTTP requests using proof-of-work to stop AI crawlers"; - homepage = "https://github.com/TecharoHQ/anubis/"; + homepage = "https://anubis.techaro.lol/"; changelog = "https://github.com/TecharoHQ/anubis/releases/tag/v${finalAttrs.version}"; license = lib.licenses.mit; maintainers = with lib.maintainers; [ knightpp soopyc ryand56 + sigmasquadron ]; mainProgram = "anubis"; };