2021-05-21 14:15:04 +02:00
|
|
|
{ lib
|
2023-05-15 12:12:06 +02:00
|
|
|
, mkYarnPackage
|
2021-05-21 14:15:04 +02:00
|
|
|
, fetchFromGitHub
|
2023-05-15 12:12:06 +02:00
|
|
|
, fetchYarnDeps
|
|
|
|
, matrix-sdk-crypto-nodejs
|
2021-05-21 14:15:04 +02:00
|
|
|
, makeWrapper
|
|
|
|
, nodejs
|
2023-05-15 12:12:06 +02:00
|
|
|
, nixosTests
|
2021-05-21 14:15:04 +02:00
|
|
|
}:
|
|
|
|
|
2023-05-15 12:12:06 +02:00
|
|
|
mkYarnPackage rec {
|
2021-05-21 14:15:04 +02:00
|
|
|
pname = "mjolnir";
|
2023-11-15 14:37:29 +01:00
|
|
|
version = "1.6.5";
|
2021-05-21 14:15:04 +02:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "matrix-org";
|
|
|
|
repo = "mjolnir";
|
2023-05-15 12:12:06 +02:00
|
|
|
rev = "refs/tags/v${version}";
|
2023-11-15 14:37:29 +01:00
|
|
|
hash = "sha256-xejFKz2MmdjMFU0X0SdI+qXTBRAwIvkcfZPQqXB9LV0=";
|
2021-05-21 14:15:04 +02:00
|
|
|
};
|
|
|
|
|
2023-05-15 12:12:06 +02:00
|
|
|
packageJSON = ./package.json;
|
2021-05-21 14:15:04 +02:00
|
|
|
|
2023-05-15 12:12:06 +02:00
|
|
|
offlineCache = fetchYarnDeps {
|
|
|
|
yarnLock = src + "/yarn.lock";
|
2023-11-15 14:37:29 +01:00
|
|
|
hash = "sha256-RpvdyxJj92k4wFjBBmWCnEpFVOXVWlHEm0SmEBUlnTM=";
|
2023-05-15 12:12:06 +02:00
|
|
|
};
|
2021-05-21 14:15:04 +02:00
|
|
|
|
2023-05-15 12:12:06 +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
|
|
|
|
2023-05-15 12:12:06 +02:00
|
|
|
nativeBuildInputs = [ makeWrapper ];
|
2021-05-21 14:15:04 +02:00
|
|
|
|
2023-05-15 12:12:06 +02:00
|
|
|
buildPhase = ''
|
|
|
|
runHook preBuild
|
2021-05-21 14:15:04 +02:00
|
|
|
|
2023-05-15 12:12:06 +02:00
|
|
|
pushd deps/${pname}
|
|
|
|
yarn run build
|
|
|
|
popd
|
2021-05-21 14:15:04 +02:00
|
|
|
|
2023-05-15 12:12:06 +02:00
|
|
|
runHook postBuild
|
|
|
|
'';
|
2021-05-21 14:15:04 +02:00
|
|
|
|
2023-05-15 12:12:06 +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
|
|
|
};
|
|
|
|
}
|