2021-06-28 23:13:55 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, buildPythonPackage
|
|
|
|
, isPy3k
|
|
|
|
, fetchFromGitHub
|
|
|
|
, substituteAll
|
|
|
|
, alsa-utils
|
|
|
|
, libnotify
|
|
|
|
, which
|
|
|
|
, jeepney
|
|
|
|
, loguru
|
2022-05-18 14:49:53 +00:00
|
|
|
, pytest
|
|
|
|
, dbus
|
2021-06-28 23:13:55 +00:00
|
|
|
, coreutils
|
|
|
|
}:
|
2020-10-07 09:15:18 +00:00
|
|
|
|
|
|
|
buildPythonPackage rec {
|
2021-06-06 07:54:09 +00:00
|
|
|
pname = "notify-py";
|
|
|
|
version = "0.3.3";
|
2020-10-07 09:15:18 +00:00
|
|
|
|
|
|
|
disabled = !isPy3k;
|
|
|
|
|
2021-06-06 07:54:09 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "ms7m";
|
|
|
|
repo = pname;
|
|
|
|
rev = "v${version}";
|
|
|
|
sha256 = "1n35adwsyhz304n4ifnsz6qzkymwhyqc8sg8d76qv5psv2xsnzlf";
|
2020-10-07 09:15:18 +00:00
|
|
|
};
|
|
|
|
|
2021-06-28 23:13:55 +00:00
|
|
|
patches = lib.optionals stdenv.isLinux [
|
|
|
|
# hardcode paths to aplay and notify-send
|
|
|
|
(substituteAll {
|
|
|
|
src = ./linux-paths.patch;
|
|
|
|
aplay = "${alsa-utils}/bin/aplay";
|
|
|
|
notifysend = "${libnotify}/bin/notify-send";
|
|
|
|
})
|
|
|
|
] ++ lib.optionals stdenv.isDarwin [
|
|
|
|
# hardcode path to which
|
|
|
|
(substituteAll {
|
|
|
|
src = ./darwin-paths.patch;
|
|
|
|
which = "${which}/bin/which";
|
|
|
|
})
|
|
|
|
];
|
|
|
|
|
2022-05-18 14:49:53 +00:00
|
|
|
propagatedBuildInputs = [
|
|
|
|
loguru
|
|
|
|
] ++ lib.optionals stdenv.isLinux [
|
|
|
|
jeepney
|
|
|
|
];
|
2020-10-07 09:15:18 +00:00
|
|
|
|
2022-05-18 14:49:53 +00:00
|
|
|
checkInputs = [
|
|
|
|
pytest
|
|
|
|
] ++ lib.optionals stdenv.isLinux [
|
|
|
|
dbus
|
|
|
|
];
|
2020-10-07 09:15:18 +00:00
|
|
|
|
2022-05-18 14:49:53 +00:00
|
|
|
checkPhase = if stdenv.isDarwin then ''
|
|
|
|
# Tests search for "afplay" binary which is built in to macOS and not available in nixpkgs
|
2021-06-06 07:54:09 +00:00
|
|
|
mkdir $TMP/bin
|
|
|
|
ln -s ${coreutils}/bin/true $TMP/bin/afplay
|
2022-05-18 14:49:53 +00:00
|
|
|
PATH="$TMP/bin:$PATH" pytest
|
|
|
|
'' else if stdenv.isLinux then ''
|
|
|
|
dbus-run-session \
|
|
|
|
--config-file=${dbus.daemon}/share/dbus-1/session.conf \
|
|
|
|
pytest
|
|
|
|
'' else ''
|
|
|
|
pytest
|
2020-10-07 09:15:18 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
pythonImportsCheck = [ "notifypy" ];
|
|
|
|
|
|
|
|
meta = with lib; {
|
2021-06-28 23:13:55 +00:00
|
|
|
description = "Cross-platform desktop notification library for Python";
|
|
|
|
homepage = "https://github.com/ms7m/notify-py";
|
2020-10-07 09:15:18 +00:00
|
|
|
license = licenses.mit;
|
2021-06-28 23:13:55 +00:00
|
|
|
maintainers = with maintainers; [ austinbutler dotlambda ];
|
2020-10-07 09:15:18 +00:00
|
|
|
};
|
|
|
|
}
|