2021-05-21 12:15:04 +00:00
|
|
|
{ lib
|
2021-05-30 15:33:09 +00:00
|
|
|
, nixosTests
|
2021-05-21 12:15:04 +00:00
|
|
|
, stdenv
|
|
|
|
, fetchFromGitHub
|
|
|
|
, makeWrapper
|
|
|
|
, nodejs
|
|
|
|
, pkgs
|
|
|
|
}:
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "mjolnir";
|
2022-07-19 06:59:13 +00:00
|
|
|
version = "1.5.0";
|
2021-05-21 12:15:04 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "matrix-org";
|
|
|
|
repo = "mjolnir";
|
|
|
|
rev = "v${version}";
|
2022-07-19 06:59:13 +00:00
|
|
|
sha256 = "YmP+r9W5e63Aw66lSQeTTbYwSF/vjPyHkoehJxtcRNw=";
|
2021-05-21 12:15:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
nodejs
|
|
|
|
makeWrapper
|
|
|
|
];
|
|
|
|
|
|
|
|
buildPhase =
|
|
|
|
let
|
|
|
|
nodeDependencies = ((import ./node-composition.nix {
|
|
|
|
inherit pkgs nodejs;
|
|
|
|
inherit (stdenv.hostPlatform) system;
|
|
|
|
}).nodeDependencies.override (old: {
|
|
|
|
# access to path '/nix/store/...-source' is forbidden in restricted mode
|
|
|
|
src = src;
|
|
|
|
dontNpmInstall = true;
|
|
|
|
}));
|
|
|
|
in
|
|
|
|
''
|
|
|
|
runHook preBuild
|
|
|
|
|
|
|
|
ln -s ${nodeDependencies}/lib/node_modules .
|
|
|
|
export PATH="${nodeDependencies}/bin:$PATH"
|
|
|
|
npm run build
|
|
|
|
|
|
|
|
runHook postBuild
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
|
|
|
|
|
|
|
mkdir -p $out/share
|
|
|
|
cp -a . $out/share/mjolnir
|
|
|
|
|
|
|
|
makeWrapper ${nodejs}/bin/node $out/bin/mjolnir \
|
|
|
|
--add-flags $out/share/mjolnir/lib/index.js
|
|
|
|
|
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
|
2021-05-30 15:33:09 +00:00
|
|
|
passthru = {
|
|
|
|
tests = {
|
|
|
|
inherit (nixosTests) mjolnir;
|
|
|
|
};
|
|
|
|
updateScript = ./update.sh;
|
|
|
|
};
|
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 ];
|
|
|
|
};
|
|
|
|
}
|