about summary refs log tree commit diff
path: root/overlays/mjolnir-package/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'overlays/mjolnir-package/default.nix')
-rw-r--r--overlays/mjolnir-package/default.nix80
1 files changed, 80 insertions, 0 deletions
diff --git a/overlays/mjolnir-package/default.nix b/overlays/mjolnir-package/default.nix
new file mode 100644
index 0000000..833124b
--- /dev/null
+++ b/overlays/mjolnir-package/default.nix
@@ -0,0 +1,80 @@
+{ lib
+, nixosTests
+, mkYarnPackage
+, fetchYarnDeps
+, fetchFromGitHub
+, makeWrapper
+, nodejs
+, pkgs
+, matrix-sdk-crypto-nodejs
+}:
+
+let
+  pin = lib.importJSON ./pin.json;
+in
+mkYarnPackage rec {
+  pname = "mjolnir";
+  inherit (pin) version;
+
+  src = fetchFromGitHub {
+    owner = "matrix-org";
+    repo = "mjolnir";
+    rev = "v${version}";
+    sha256 = pin.srcSha256;
+  };
+
+  packageJSON = ./package.json;
+  offlineCache = fetchYarnDeps {
+    yarnLock = "${src}/yarn.lock";
+    sha256 = pin.yarnSha256;
+  };
+
+  packageResolutions = {
+    "@matrix-org/matrix-sdk-crypto-nodejs" = "${matrix-sdk-crypto-nodejs}/lib/node_modules/@matrix-org/matrix-sdk-crypto-nodejs";
+  };
+
+  nativeBuildInputs = [
+    makeWrapper
+  ];
+
+  buildPhase = ''
+    runHook preBuild
+    yarn --offline build
+    runHook postBuild
+  '';
+
+  postInstall = ''
+    makeWrapper ${nodejs}/bin/node $out/bin/mjolnir \
+      --add-flags $out/libexec/mjolnir/deps/mjolnir/lib/index.js
+  '';
+
+  doDist = false;
+
+  passthru = {
+    tests = {
+      inherit (nixosTests) mjolnir;
+    };
+    updateScript = ./update.sh;
+  };
+
+  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 ];
+  };
+}