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