about summary refs log tree commit diff
path: root/nixpkgs/pkgs/tools/misc/ntfy/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/tools/misc/ntfy/default.nix')
-rw-r--r--nixpkgs/pkgs/tools/misc/ntfy/default.nix42
1 files changed, 36 insertions, 6 deletions
diff --git a/nixpkgs/pkgs/tools/misc/ntfy/default.nix b/nixpkgs/pkgs/tools/misc/ntfy/default.nix
index 8bee0c304f7f..25239554bf2b 100644
--- a/nixpkgs/pkgs/tools/misc/ntfy/default.nix
+++ b/nixpkgs/pkgs/tools/misc/ntfy/default.nix
@@ -1,13 +1,31 @@
 { lib
+, stdenv
 , python39
+, fetchPypi
 , fetchFromGitHub
 , fetchpatch
+, withXmpp ? !stdenv.isDarwin
+, withMatrix ? true
+, withSlack ? true
+, withEmoji ? true
+, withPid ? true
+, withDbus ? stdenv.isLinux
 }:
 
 let
   python = python39.override {
     packageOverrides = self: super: {
       ntfy-webpush = self.callPackage ./webpush.nix { };
+
+      # databases, on which slack-sdk depends, is incompatible with SQLAlchemy 2.0
+      sqlalchemy = super.sqlalchemy.overridePythonAttrs (old: rec {
+        version = "1.4.46";
+        src = fetchPypi {
+          pname = "SQLAlchemy";
+          inherit version;
+          hash = "sha256-aRO4JH2KKS74MVFipRkx4rQM6RaB8bbxj2lwRSAMSjA=";
+        };
+      });
     };
   };
 in python.pkgs.buildPythonApplication rec {
@@ -23,20 +41,26 @@ in python.pkgs.buildPythonApplication rec {
     sha256 = "09f02cn4i1l2aksb3azwfb70axqhn7d0d0vl2r6640hqr74nc1cv";
   };
 
-  checkInputs = with python.pkgs; [
+  nativeCheckInputs = with python.pkgs; [
     mock
   ];
 
-  propagatedBuildInputs = with python.pkgs; [
+  propagatedBuildInputs = with python.pkgs; ([
     requests ruamel-yaml appdirs
+    ntfy-webpush
+  ] ++ (lib.optionals withXmpp [
     sleekxmpp dnspython
+  ]) ++ (lib.optionals withMatrix [
+    matrix-client
+  ]) ++ (lib.optionals withSlack [
+    slack-sdk
+  ]) ++ (lib.optionals withEmoji [
     emoji
+  ]) ++ (lib.optionals withPid [
     psutil
-    matrix-client
+  ]) ++ (lib.optionals withDbus [
     dbus-python
-    ntfy-webpush
-    slack-sdk
-  ];
+  ]));
 
   patches = [
     # Fix Slack integration no longer working.
@@ -55,6 +79,12 @@ in python.pkgs.buildPythonApplication rec {
     })
   ];
 
+  postPatch = ''
+    # We disable the Darwin specific things because it relies on pyobjc, which we don't have.
+    substituteInPlace setup.py \
+      --replace "':sys_platform == \"darwin\"'" "'darwin'"
+  '';
+
   checkPhase = ''
     HOME=$(mktemp -d) ${python.interpreter} setup.py test
   '';