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