1{ lib 2, stdenv 3, buildPythonPackage 4, isPy3k 5, fetchFromGitHub 6, substituteAll 7, alsa-utils 8, libnotify 9, which 10, jeepney 11, loguru 12, pytest 13, dbus 14, coreutils 15}: 16 17buildPythonPackage rec { 18 pname = "notify-py"; 19 version = "0.3.3"; 20 21 disabled = !isPy3k; 22 23 src = fetchFromGitHub { 24 owner = "ms7m"; 25 repo = pname; 26 rev = "v${version}"; 27 sha256 = "1n35adwsyhz304n4ifnsz6qzkymwhyqc8sg8d76qv5psv2xsnzlf"; 28 }; 29 30 patches = lib.optionals stdenv.isLinux [ 31 # hardcode paths to aplay and notify-send 32 (substituteAll { 33 src = ./linux-paths.patch; 34 aplay = "${alsa-utils}/bin/aplay"; 35 notifysend = "${libnotify}/bin/notify-send"; 36 }) 37 ] ++ lib.optionals stdenv.isDarwin [ 38 # hardcode path to which 39 (substituteAll { 40 src = ./darwin-paths.patch; 41 which = "${which}/bin/which"; 42 }) 43 ]; 44 45 propagatedBuildInputs = [ 46 loguru 47 ] ++ lib.optionals stdenv.isLinux [ 48 jeepney 49 ]; 50 51 checkInputs = [ 52 pytest 53 ] ++ lib.optionals stdenv.isLinux [ 54 dbus 55 ]; 56 57 checkPhase = if stdenv.isDarwin then '' 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 '' else if stdenv.isLinux then '' 63 dbus-run-session \ 64 --config-file=${dbus.daemon}/share/dbus-1/session.conf \ 65 pytest 66 '' else '' 67 pytest 68 ''; 69 70 pythonImportsCheck = [ "notifypy" ]; 71 72 meta = with lib; { 73 description = "Cross-platform desktop notification library for Python"; 74 homepage = "https://github.com/ms7m/notify-py"; 75 license = licenses.mit; 76 maintainers = with maintainers; [ austinbutler dotlambda ]; 77 }; 78}