Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
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.38";
22
23 disabled = pythonOlder "3.6";
24
25 format = "pyproject";
26
27 src = fetchFromGitHub {
28 owner = "ms7m";
29 repo = pname;
30 rev = "v${version}";
31 hash = "sha256-wlA7a10f4PYP3dYYwZqMULQ5FMCXpOUOTxXzEEVZCsI=";
32 };
33
34 patches = lib.optionals stdenv.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 ] ++ lib.optionals stdenv.isDarwin [
42 # hardcode path to which
43 (substituteAll {
44 src = ./darwin-paths.patch;
45 which = "${which}/bin/which";
46 })
47 ];
48
49 nativeBuildInputs = [
50 poetry-core
51 pythonRelaxDepsHook
52 ];
53
54 pythonRelaxDeps = [
55 "loguru"
56 ];
57
58 propagatedBuildInputs = [
59 loguru
60 ] ++ lib.optionals stdenv.isLinux [
61 jeepney
62 ];
63
64 checkInputs = [
65 pytest
66 ] ++ lib.optionals stdenv.isLinux [
67 dbus
68 ];
69
70 checkPhase = if stdenv.isDarwin then ''
71 # Tests search for "afplay" binary which is built in to macOS and not available in nixpkgs
72 mkdir $TMP/bin
73 ln -s ${coreutils}/bin/true $TMP/bin/afplay
74 PATH="$TMP/bin:$PATH" pytest
75 '' else if stdenv.isLinux then ''
76 dbus-run-session \
77 --config-file=${dbus}/share/dbus-1/session.conf \
78 pytest
79 '' else ''
80 pytest
81 '';
82
83 # GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name
84 # org.freedesktop.Notifications was not provided by any .service files
85 doCheck = false;
86
87 pythonImportsCheck = [ "notifypy" ];
88
89 meta = with lib; {
90 description = "Cross-platform desktop notification library for Python";
91 homepage = "https://github.com/ms7m/notify-py";
92 license = licenses.mit;
93 maintainers = with maintainers; [ austinbutler dotlambda ];
94 };
95}