Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s
99 lines
2.2 KiB
Nix
99 lines
2.2 KiB
Nix
{
|
|
lib,
|
|
buildGoModule,
|
|
fetchFromGitHub,
|
|
fetchNpmDeps,
|
|
nixosTests,
|
|
stdenv,
|
|
npmHooks,
|
|
nodejs,
|
|
esbuild,
|
|
brotli,
|
|
zstd,
|
|
nix-update-script,
|
|
}:
|
|
|
|
buildGoModule (finalAttrs: {
|
|
pname = "anubis";
|
|
version = "1.22.0";
|
|
|
|
src = fetchFromGitHub {
|
|
owner = "TecharoHQ";
|
|
repo = "anubis";
|
|
tag = "v${finalAttrs.version}";
|
|
hash = "sha256-LOYBl9r00AJljGvlacd506cLeMr8Ndh817/ZIw46Uu0=";
|
|
};
|
|
|
|
vendorHash = "sha256-/iTAbwYSHTz9SrJ0vrAXsA+3yS0jUreJDF52gju9CgU=";
|
|
|
|
npmDeps = fetchNpmDeps {
|
|
name = "anubis-npm-deps";
|
|
inherit (finalAttrs) src;
|
|
hash = "sha256-s+OxVf6Iysobfuo0nAh5qF157opD2sR5D+7awAx6GTs=";
|
|
};
|
|
|
|
nativeBuildInputs = [
|
|
esbuild
|
|
brotli
|
|
zstd
|
|
|
|
nodejs
|
|
npmHooks.npmConfigHook
|
|
];
|
|
|
|
subPackages = [ "cmd/anubis" ];
|
|
|
|
ldflags = [
|
|
"-s"
|
|
"-w"
|
|
"-X=github.com/TecharoHQ/anubis.Version=v${finalAttrs.version}"
|
|
]
|
|
++ lib.optionals stdenv.hostPlatform.isLinux [ "-extldflags=-static" ];
|
|
|
|
prePatch = ''
|
|
# we must forcefully disable the hook when creating the go vendor archive
|
|
if [[ $name =~ go-modules ]]; then
|
|
npmConfigHook() { true; }
|
|
fi
|
|
'';
|
|
|
|
postPatch = ''
|
|
patchShebangs ./web/build.sh ./lib/challenge/preact/build.sh
|
|
'';
|
|
|
|
preBuild = ''
|
|
# do not run when creating go vendor archive
|
|
if [[ ! $name =~ go-modules ]]; then
|
|
# https://github.com/TecharoHQ/anubis/blob/main/xess/build.sh
|
|
npx postcss ./xess/xess.css -o xess/xess.min.css
|
|
go generate ./...
|
|
./web/build.sh
|
|
fi
|
|
'';
|
|
|
|
preCheck = ''
|
|
export DONT_USE_NETWORK=1
|
|
'';
|
|
|
|
passthru = {
|
|
tests = { inherit (nixosTests) anubis; };
|
|
updateScript = nix-update-script { extraArgs = [ "--version-regex=^v(\\d+\\.\\d+\\.\\d+)$" ]; };
|
|
};
|
|
|
|
meta = {
|
|
description = "Weighs the soul of incoming HTTP requests using proof-of-work to stop AI crawlers";
|
|
homepage = "https://anubis.techaro.lol/";
|
|
downloadPage = "https://github.com/TecharoHQ/anubis";
|
|
changelog = "https://github.com/TecharoHQ/anubis/releases/tag/v${finalAttrs.version}";
|
|
license = lib.licenses.mit;
|
|
maintainers = with lib.maintainers; [
|
|
knightpp
|
|
soopyc
|
|
ryand56
|
|
sigmasquadron
|
|
defelo
|
|
];
|
|
mainProgram = "anubis";
|
|
};
|
|
})
|