2025-03-21 20:10:55 +02:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
buildGoModule,
|
|
|
|
fetchFromGitHub,
|
2025-05-10 18:03:56 +02:00
|
|
|
nixosTests,
|
2025-03-21 20:10:55 +02:00
|
|
|
stdenv,
|
2025-06-11 20:49:14 +02:00
|
|
|
buildNpmPackage,
|
2025-05-07 10:03:56 -03:00
|
|
|
|
2025-04-13 17:37:01 +00:00
|
|
|
esbuild,
|
|
|
|
brotli,
|
|
|
|
zstd,
|
2025-03-21 20:10:55 +02:00
|
|
|
}:
|
2025-05-07 10:03:56 -03:00
|
|
|
|
|
|
|
buildGoModule (finalAttrs: {
|
2025-03-21 20:10:55 +02:00
|
|
|
pname = "anubis";
|
2025-07-23 17:38:19 +00:00
|
|
|
version = "1.21.3";
|
2025-03-21 20:10:55 +02:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "TecharoHQ";
|
|
|
|
repo = "anubis";
|
2025-05-07 10:03:56 -03:00
|
|
|
tag = "v${finalAttrs.version}";
|
2025-07-23 17:38:19 +00:00
|
|
|
hash = "sha256-CMFd9che+D1ot1Iqk0VcJmna0xIqHlRIvNnzYo+q+RU=";
|
2025-04-13 17:37:01 +00:00
|
|
|
};
|
|
|
|
|
2025-07-17 15:47:36 +00:00
|
|
|
vendorHash = "sha256-cWkC3Bqut5h3hHh5tPIPeHMnkwoqKMnG1x40uCtUIwI=";
|
2025-03-21 20:10:55 +02:00
|
|
|
|
2025-04-13 17:37:01 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
esbuild
|
|
|
|
brotli
|
|
|
|
zstd
|
|
|
|
];
|
2025-03-21 20:10:55 +02:00
|
|
|
|
2025-06-11 20:49:14 +02:00
|
|
|
xess = buildNpmPackage {
|
|
|
|
pname = "anubis-xess";
|
|
|
|
inherit (finalAttrs) version src;
|
|
|
|
|
2025-07-23 17:38:19 +00:00
|
|
|
npmDepsHash = "sha256-NJMUXGXcaY8l1WIbvCn+aIknVuagR7X8gRkme9xpYQ0=";
|
2025-06-11 20:49:14 +02:00
|
|
|
|
|
|
|
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
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2025-06-11 21:20:14 +02:00
|
|
|
subPackages = [ "cmd/anubis" ];
|
2025-03-21 20:10:55 +02:00
|
|
|
|
2025-06-11 21:20:14 +02:00
|
|
|
ldflags = [
|
|
|
|
"-s"
|
|
|
|
"-w"
|
|
|
|
"-X=github.com/TecharoHQ/anubis.Version=v${finalAttrs.version}"
|
|
|
|
]
|
|
|
|
++ lib.optionals stdenv.hostPlatform.isLinux [ "-extldflags=-static" ];
|
2025-03-21 20:10:55 +02:00
|
|
|
|
2025-04-13 17:37:01 +00:00
|
|
|
postPatch = ''
|
|
|
|
patchShebangs ./web/build.sh
|
|
|
|
'';
|
|
|
|
|
|
|
|
preBuild = ''
|
2025-06-11 20:49:14 +02:00
|
|
|
go generate ./... && ./web/build.sh && cp -r ${finalAttrs.xess}/xess.min.css ./xess
|
2025-04-13 17:37:01 +00:00
|
|
|
'';
|
|
|
|
|
2025-03-21 20:10:55 +02:00
|
|
|
preCheck = ''
|
|
|
|
export DONT_USE_NETWORK=1
|
|
|
|
'';
|
|
|
|
|
2025-05-07 10:03:56 -03:00
|
|
|
passthru.tests = { inherit (nixosTests) anubis; };
|
2025-06-11 20:47:38 +02:00
|
|
|
passthru.updateScript = ./update.sh;
|
2025-03-21 20:10:55 +02:00
|
|
|
|
|
|
|
meta = {
|
|
|
|
description = "Weighs the soul of incoming HTTP requests using proof-of-work to stop AI crawlers";
|
2025-05-07 10:03:56 -03:00
|
|
|
homepage = "https://anubis.techaro.lol/";
|
2025-06-11 20:59:06 +02:00
|
|
|
downloadPage = "https://github.com/TecharoHQ/anubis";
|
2025-03-21 20:10:55 +02:00
|
|
|
changelog = "https://github.com/TecharoHQ/anubis/releases/tag/v${finalAttrs.version}";
|
|
|
|
license = lib.licenses.mit;
|
2025-03-28 16:56:58 +08:00
|
|
|
maintainers = with lib.maintainers; [
|
|
|
|
knightpp
|
|
|
|
soopyc
|
2025-04-28 00:00:06 -06:00
|
|
|
ryand56
|
2025-05-07 10:03:56 -03:00
|
|
|
sigmasquadron
|
2025-06-11 20:48:16 +02:00
|
|
|
defelo
|
2025-03-28 16:56:58 +08:00
|
|
|
];
|
2025-03-21 20:10:55 +02:00
|
|
|
mainProgram = "anubis";
|
|
|
|
};
|
|
|
|
})
|