1{ lib
2, buildPythonPackage
3, fetchFromGitHub
4, nose
5, dbus
6, dbus-python
7, pygobject3
8, bluez
9, networkmanager
10, setuptools-scm
11, runCommand
12}:
13
14let
15 # Cannot just add it to path in preCheck since that attribute will be passed to
16 # mkDerivation even with doCheck = false, causing a dependency cycle.
17 pbap-client = runCommand "pbap-client" { } ''
18 mkdir -p "$out/bin"
19 ln -s "${bluez.test}/test/pbap-client" "$out/bin/pbap-client"
20 '';
21in buildPythonPackage rec {
22 pname = "python-dbusmock";
23 version = "0.28.4";
24
25 src = fetchFromGitHub {
26 owner = "martinpitt";
27 repo = pname;
28 rev = "refs/tags/${version}";
29 sha256 = "sha256-gsGg9zHVyDTCVZmFUI8qqXDt0ui+o3hPwjRlsYUmShg=";
30 };
31
32 SETUPTOOLS_SCM_PRETEND_VERSION = version;
33
34 nativeBuildInputs = [
35 setuptools-scm
36 ];
37
38 propagatedBuildInputs = [
39 dbus-python
40 ];
41
42 checkInputs = [
43 dbus
44 pygobject3
45 bluez
46 pbap-client
47 networkmanager
48 nose
49 ];
50
51 # TODO: Get the rest of these tests running?
52 NOSE_EXCLUDE = lib.concatStringsSep "," [
53 "test_bluez4" # NixOS ships BlueZ5
54 # These appear to fail because they're expecting to run in an Ubuntu chroot?
55 "test_everything" # BlueZ5 OBEX
56 "test_polkitd"
57 "test_consolekit"
58 "test_api"
59 "test_logind"
60 "test_notification_daemon"
61 "test_ofono"
62 "test_gnome_screensaver"
63 "test_cli"
64 "test_timedated"
65 "test_upower"
66 # needs glib
67 "test_accounts_service"
68 # needs dbus-daemon active
69 "test_systemd"
70 # Very slow, consider disabling?
71 # "test_networkmanager"
72 ];
73
74 checkPhase = ''
75 runHook preCheck
76 nosetests -v
77 runHook postCheck
78 '';
79
80 meta = with lib; {
81 description = "Mock D-Bus objects for tests";
82 homepage = "https://github.com/martinpitt/python-dbusmock";
83 license = licenses.lgpl3Plus;
84 maintainers = with maintainers; [ callahad ];
85 platforms = platforms.linux;
86 };
87}