1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 pythonOlder,
6 fetchFromGitHub,
7 substituteAll,
8 alsa-utils,
9 libnotify,
10 which,
11 poetry-core,
12 jeepney,
13 loguru,
14 pytest,
15 dbus,
16 coreutils,
17}:
18
19buildPythonPackage rec {
20 pname = "notify-py";
21 version = "0.3.43";
22 format = "pyproject";
23
24 disabled = pythonOlder "3.6";
25
26 src = fetchFromGitHub {
27 owner = "ms7m";
28 repo = pname;
29 rev = "refs/tags/v${version}";
30 hash = "sha256-4PJ/0dLG3bWDuF1G/qUmvNaIUFXgPP2S/0uhZz86WRA=";
31 };
32
33 patches =
34 lib.optionals stdenv.hostPlatform.isLinux [
35 # hardcode paths to aplay and notify-send
36 (substituteAll {
37 src = ./linux-paths.patch;
38 aplay = "${alsa-utils}/bin/aplay";
39 notifysend = "${libnotify}/bin/notify-send";
40 })
41 ]
42 ++ lib.optionals stdenv.hostPlatform.isDarwin [
43 # hardcode path to which
44 (substituteAll {
45 src = ./darwin-paths.patch;
46 which = "${which}/bin/which";
47 })
48 ];
49
50 nativeBuildInputs = [
51 poetry-core
52 ];
53
54 pythonRelaxDeps = [ "loguru" ];
55
56 propagatedBuildInputs = [ loguru ] ++ lib.optionals stdenv.hostPlatform.isLinux [ jeepney ];
57
58 nativeCheckInputs = [ pytest ] ++ lib.optionals stdenv.hostPlatform.isLinux [ dbus ];
59
60 checkPhase =
61 if stdenv.hostPlatform.isDarwin then
62 ''
63 # Tests search for "afplay" binary which is built in to macOS and not available in nixpkgs
64 mkdir $TMP/bin
65 ln -s ${coreutils}/bin/true $TMP/bin/afplay
66 PATH="$TMP/bin:$PATH" pytest
67 ''
68 else if stdenv.hostPlatform.isLinux then
69 ''
70 dbus-run-session \
71 --config-file=${dbus}/share/dbus-1/session.conf \
72 pytest
73 ''
74 else
75 ''
76 pytest
77 '';
78
79 # GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name
80 # org.freedesktop.Notifications was not provided by any .service files
81 doCheck = false;
82
83 pythonImportsCheck = [ "notifypy" ];
84
85 meta = with lib; {
86 description = "Cross-platform desktop notification library for Python";
87 mainProgram = "notifypy";
88 homepage = "https://github.com/ms7m/notify-py";
89 changelog = "https://github.com/ms7m/notify-py/releases/tag/v${version}";
90 license = licenses.mit;
91 maintainers = with maintainers; [
92 austinbutler
93 dotlambda
94 ];
95 };
96}