nixpkgs/pkgs/servers/mjolnir/default.nix

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

77 lines
1.9 KiB
Nix
Raw Normal View History

2021-05-21 12:15:04 +00:00
{ lib
, mkYarnPackage
2021-05-21 12:15:04 +00:00
, fetchFromGitHub
, fetchYarnDeps
, matrix-sdk-crypto-nodejs
2021-05-21 12:15:04 +00:00
, makeWrapper
, nodejs
, nixosTests
2021-05-21 12:15:04 +00:00
}:
mkYarnPackage rec {
2021-05-21 12:15:04 +00:00
pname = "mjolnir";
version = "1.6.4";
2021-05-21 12:15:04 +00:00
src = fetchFromGitHub {
owner = "matrix-org";
repo = "mjolnir";
rev = "refs/tags/v${version}";
hash = "sha256-/vnojWLpu/fktqPUhAdL1QTESxDwFrBVYAkyF79Fj9w=";
2021-05-21 12:15:04 +00:00
};
packageJSON = ./package.json;
2021-05-21 12:15:04 +00:00
offlineCache = fetchYarnDeps {
yarnLock = src + "/yarn.lock";
hash = "sha256-B4s0CYr5Ihoh4gkckwZ3z0Nb4LMET48WvRXuhk3fpQM=";
};
2021-05-21 12:15:04 +00:00
packageResolutions = {
"@matrix-org/matrix-sdk-crypto-nodejs" = "${matrix-sdk-crypto-nodejs}/lib/node_modules/@matrix-org/matrix-sdk-crypto-nodejs";
};
2021-05-21 12:15:04 +00:00
nativeBuildInputs = [ makeWrapper ];
2021-05-21 12:15:04 +00:00
buildPhase = ''
runHook preBuild
2021-05-21 12:15:04 +00:00
pushd deps/${pname}
yarn run build
popd
2021-05-21 12:15:04 +00:00
runHook postBuild
'';
2021-05-21 12:15:04 +00:00
postInstall = ''
makeWrapper ${nodejs}/bin/node "$out/bin/mjolnir" \
--add-flags "$out/libexec/mjolnir/deps/mjolnir/lib/index.js"
2021-05-21 12:15:04 +00:00
'';
2021-05-30 15:33:09 +00:00
passthru = {
tests = {
inherit (nixosTests) mjolnir;
};
};
2021-05-21 12:15:04 +00: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 ];
};
}