nixpkgs/pkgs/servers/mjolnir/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

78 lines
2 KiB
Nix
Raw Normal View History

2021-05-21 14:15:04 +02:00
{ lib
, mkYarnPackage
2021-05-21 14:15:04 +02:00
, fetchFromGitHub
, fetchYarnDeps
, matrix-sdk-crypto-nodejs
2021-05-21 14:15:04 +02:00
, makeWrapper
, nodejs
, nixosTests
2021-05-21 14:15:04 +02:00
}:
mkYarnPackage rec {
2021-05-21 14:15:04 +02:00
pname = "mjolnir";
version = "1.6.5";
2021-05-21 14:15:04 +02:00
src = fetchFromGitHub {
owner = "matrix-org";
repo = "mjolnir";
rev = "refs/tags/v${version}";
hash = "sha256-xejFKz2MmdjMFU0X0SdI+qXTBRAwIvkcfZPQqXB9LV0=";
2021-05-21 14:15:04 +02:00
};
packageJSON = ./package.json;
2021-05-21 14:15:04 +02:00
offlineCache = fetchYarnDeps {
yarnLock = src + "/yarn.lock";
hash = "sha256-RpvdyxJj92k4wFjBBmWCnEpFVOXVWlHEm0SmEBUlnTM=";
};
2021-05-21 14:15:04 +02:00
packageResolutions = {
"@matrix-org/matrix-sdk-crypto-nodejs" = "${matrix-sdk-crypto-nodejs}/lib/node_modules/@matrix-org/matrix-sdk-crypto-nodejs";
};
2021-05-21 14:15:04 +02:00
nativeBuildInputs = [ makeWrapper ];
2021-05-21 14:15:04 +02:00
buildPhase = ''
runHook preBuild
2021-05-21 14:15:04 +02:00
pushd deps/${pname}
yarn run build
popd
2021-05-21 14:15:04 +02:00
runHook postBuild
'';
2021-05-21 14:15:04 +02:00
postInstall = ''
makeWrapper ${nodejs}/bin/node "$out/bin/mjolnir" \
--add-flags "$out/libexec/mjolnir/deps/mjolnir/lib/index.js"
2021-05-21 14:15:04 +02:00
'';
2021-05-30 17:33:09 +02:00
passthru = {
tests = {
inherit (nixosTests) mjolnir;
};
};
2021-05-21 14:15:04 +02:00
meta = with lib; {
description = "A moderation tool for Matrix";
homepage = "https://github.com/matrix-org/mjolnir";
longDescription = ''
As an all-in-one moderation tool, it can protect your server from
malicious invites, spam messages, and whatever else you don't want.
In addition to server-level protection, Mjolnir is great for communities
wanting to protect their rooms without having to use their personal
accounts for moderation.
The bot by default includes support for bans, redactions, anti-spam,
server ACLs, room directory changes, room alias transfers, account
deactivation, room shutdown, and more.
A Synapse module is also available to apply the same rulesets the bot
uses across an entire homeserver.
'';
license = licenses.asl20;
maintainers = with maintainers; [ jojosch ];
2023-11-23 22:09:35 +01:00
mainProgram = "mjolnir";
2021-05-21 14:15:04 +02:00
};
}