1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 pythonOlder,
6 fetchFromGitHub,
7 replaceVars,
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 = "notify-py";
29 tag = "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 (replaceVars ./linux-paths.patch {
37 aplay = "${alsa-utils}/bin/aplay";
38 notifysend = "${libnotify}/bin/notify-send";
39 })
40 ]
41 ++ lib.optionals stdenv.hostPlatform.isDarwin [
42 # hardcode path to which
43 (replaceVars ./darwin-paths.patch {
44 which = "${which}/bin/which";
45 })
46 ];
47
48 nativeBuildInputs = [
49 poetry-core
50 ];
51
52 pythonRelaxDeps = [ "loguru" ];
53
54 propagatedBuildInputs = [ loguru ] ++ lib.optionals stdenv.hostPlatform.isLinux [ jeepney ];
55
56 nativeCheckInputs = [ pytest ] ++ lib.optionals stdenv.hostPlatform.isLinux [ dbus ];
57
58 checkPhase =
59 if stdenv.hostPlatform.isDarwin then
60 ''
61 # Tests search for "afplay" binary which is built in to macOS and not available in nixpkgs
62 mkdir $TMP/bin
63 ln -s ${coreutils}/bin/true $TMP/bin/afplay
64 PATH="$TMP/bin:$PATH" pytest
65 ''
66 else if stdenv.hostPlatform.isLinux then
67 ''
68 dbus-run-session \
69 --config-file=${dbus}/share/dbus-1/session.conf \
70 pytest
71 ''
72 else
73 ''
74 pytest
75 '';
76
77 # GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name
78 # org.freedesktop.Notifications was not provided by any .service files
79 doCheck = false;
80
81 pythonImportsCheck = [ "notifypy" ];
82
83 meta = with lib; {
84 description = "Cross-platform desktop notification library for Python";
85 mainProgram = "notifypy";
86 homepage = "https://github.com/ms7m/notify-py";
87 changelog = "https://github.com/ms7m/notify-py/releases/tag/v${version}";
88 license = licenses.mit;
89 maintainers = with maintainers; [
90 austinbutler
91 dotlambda
92 ];
93 };
94}