nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 stdenv,
3 lib,
4 fetchFromGitLab,
5 fetchpatch,
6 gitUpdater,
7 testers,
8 cmake,
9 cmake-extras,
10 dbus,
11 dbus-test-runner,
12 gtest,
13 pkg-config,
14 procps,
15 python3,
16 qtbase,
17}:
18
19stdenv.mkDerivation (finalAttrs: {
20 pname = "libqtdbustest";
21 version = "0.4.0";
22
23 src = fetchFromGitLab {
24 owner = "ubports";
25 repo = "development/core/libqtdbustest";
26 rev = finalAttrs.version;
27 hash = "sha256-49YIkaQ2ceJxaPLkzOg+L3bwiPzoB36xU7skRh4vYQg=";
28 };
29
30 patches = [
31 # Tests are overly pedantic when looking for launched process names in `ps`, break on python wrapper vs real python
32 # Just check if basename + arguments match, like libqtdbusmock does
33 ./less-pedantic-process-finding.patch
34
35 # Disable QProcess start timeout
36 (fetchpatch {
37 url = "https://salsa.debian.org/ubports-team/libqtdbustest/-/raw/debian/0.3.2-3/debian/patches/1003_no-QProcess-waitForstarted-timeout.patch";
38 hash = "sha256-ThDbn6URvkj5ARDMj+xO0fb1Qh2YQRzVy24O03KglHI=";
39 })
40
41 # More robust dbus address reading
42 (fetchpatch {
43 url = "https://salsa.debian.org/ubports-team/libqtdbustest/-/raw/debian/0.3.2-3/debian/patches/1004_make-reading-address-from-dbus-daemon-more-robust.patch";
44 hash = "sha256-hq8pdducp/udxoGWGt1dgL/7VHcbJO/oT1dOY1zew8M=";
45 })
46 ];
47
48 strictDeps = true;
49
50 postPatch = lib.optionalString (!finalAttrs.finalPackage.doCheck) ''
51 # Don't build tests when we're not running them
52 sed -i -e '/add_subdirectory(tests)/d' CMakeLists.txt
53 '';
54
55 nativeBuildInputs = [
56 cmake
57 pkg-config
58 ];
59
60 buildInputs = [
61 cmake-extras
62 qtbase
63 ];
64
65 nativeCheckInputs = [
66 dbus
67 dbus-test-runner
68 procps
69 (python3.withPackages (
70 ps: with ps; [
71 python-dbusmock
72 ]
73 ))
74 ];
75
76 checkInputs = [
77 gtest
78 ];
79
80 dontWrapQtApps = true;
81
82 doCheck = stdenv.buildPlatform.canExecute stdenv.hostPlatform;
83
84 enableParallelChecking = false;
85
86 checkPhase = ''
87 runHook preCheck
88
89 dbus-test-runner -t make -p test -p "''${enableParallelChecking:+-j $NIX_BUILD_CORES}"
90
91 runHook postCheck
92 '';
93
94 passthru = {
95 tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
96 updateScript = gitUpdater { };
97 };
98
99 meta = {
100 description = "Library for testing DBus interactions using Qt";
101 homepage = "https://gitlab.com/ubports/development/core/libqtdbustest";
102 license = lib.licenses.lgpl3Only;
103 platforms = lib.platforms.unix;
104 teams = [ lib.teams.lomiri ];
105 mainProgram = "qdbus-simple-test-runner";
106 pkgConfigModules = [
107 "libqtdbustest-1"
108 ];
109 };
110})