anubis: 1.21.3 -> 1.22.0

The new preact challenge uses go generate and depends on the
node_modules directory being available. To make things easier and more
closely to how upstream builds things, I removed the xess package and
added some, lets be honest to ourselves, hacks to build the new things
without breaking the FODs.

Changelog: https://github.com/TecharoHQ/anubis/releases/tag/v1.22.0
Co-authored-by: Ryan Omasta <git@ryand.ca>

+35 -36
+35 -28
pkgs/by-name/an/anubis/package.nix
··· 2 2 lib, 3 3 buildGoModule, 4 4 fetchFromGitHub, 5 + fetchNpmDeps, 5 6 nixosTests, 6 7 stdenv, 7 - buildNpmPackage, 8 - 8 + npmHooks, 9 + nodejs, 9 10 esbuild, 10 11 brotli, 11 12 zstd, 13 + nix-update-script, 12 14 }: 13 15 14 16 buildGoModule (finalAttrs: { 15 17 pname = "anubis"; 16 - version = "1.21.3"; 18 + version = "1.22.0"; 17 19 18 20 src = fetchFromGitHub { 19 21 owner = "TecharoHQ"; 20 22 repo = "anubis"; 21 23 tag = "v${finalAttrs.version}"; 22 - hash = "sha256-CMFd9che+D1ot1Iqk0VcJmna0xIqHlRIvNnzYo+q+RU="; 24 + hash = "sha256-LOYBl9r00AJljGvlacd506cLeMr8Ndh817/ZIw46Uu0="; 23 25 }; 24 26 25 - vendorHash = "sha256-cWkC3Bqut5h3hHh5tPIPeHMnkwoqKMnG1x40uCtUIwI="; 27 + vendorHash = "sha256-/iTAbwYSHTz9SrJ0vrAXsA+3yS0jUreJDF52gju9CgU="; 28 + 29 + npmDeps = fetchNpmDeps { 30 + name = "anubis-npm-deps"; 31 + inherit (finalAttrs) src; 32 + hash = "sha256-s+OxVf6Iysobfuo0nAh5qF157opD2sR5D+7awAx6GTs="; 33 + }; 26 34 27 35 nativeBuildInputs = [ 28 36 esbuild 29 37 brotli 30 38 zstd 31 - ]; 32 39 33 - xess = buildNpmPackage { 34 - pname = "anubis-xess"; 35 - inherit (finalAttrs) version src; 36 - 37 - npmDepsHash = "sha256-NJMUXGXcaY8l1WIbvCn+aIknVuagR7X8gRkme9xpYQ0="; 38 - 39 - buildPhase = '' 40 - runHook preBuild 41 - npx postcss ./xess/xess.css -o xess.min.css 42 - runHook postBuild 43 - ''; 44 - 45 - installPhase = '' 46 - runHook preInstall 47 - install -Dm644 xess.min.css $out/xess.min.css 48 - runHook postInstall 49 - ''; 50 - }; 40 + nodejs 41 + npmHooks.npmConfigHook 42 + ]; 51 43 52 44 subPackages = [ "cmd/anubis" ]; 53 45 ··· 58 50 ] 59 51 ++ lib.optionals stdenv.hostPlatform.isLinux [ "-extldflags=-static" ]; 60 52 53 + prePatch = '' 54 + # we must forcefully disable the hook when creating the go vendor archive 55 + if [[ $name =~ go-modules ]]; then 56 + npmConfigHook() { true; } 57 + fi 58 + ''; 59 + 61 60 postPatch = '' 62 - patchShebangs ./web/build.sh 61 + patchShebangs ./web/build.sh ./lib/challenge/preact/build.sh 63 62 ''; 64 63 65 64 preBuild = '' 66 - go generate ./... && ./web/build.sh && cp -r ${finalAttrs.xess}/xess.min.css ./xess 65 + # do not run when creating go vendor archive 66 + if [[ ! $name =~ go-modules ]]; then 67 + # https://github.com/TecharoHQ/anubis/blob/main/xess/build.sh 68 + npx postcss ./xess/xess.css -o xess/xess.min.css 69 + go generate ./... 70 + ./web/build.sh 71 + fi 67 72 ''; 68 73 69 74 preCheck = '' 70 75 export DONT_USE_NETWORK=1 71 76 ''; 72 77 73 - passthru.tests = { inherit (nixosTests) anubis; }; 74 - passthru.updateScript = ./update.sh; 78 + passthru = { 79 + tests = { inherit (nixosTests) anubis; }; 80 + updateScript = nix-update-script { extraArgs = [ "--version-regex=^v(\\d+\\.\\d+\\.\\d+)$" ]; }; 81 + }; 75 82 76 83 meta = { 77 84 description = "Weighs the soul of incoming HTTP requests using proof-of-work to stop AI crawlers";
-8
pkgs/by-name/an/anubis/update.sh
··· 1 - #!/usr/bin/env nix-shell 2 - #!nix-shell -i bash -p nix-update 3 - 4 - set -euo pipefail 5 - 6 - nix-update anubis --src-only --version-regex='^v(\d+\.\d+\.\d+)$' 7 - nix-update anubis.xess --version=skip 8 - nix-update anubis --version=skip