tangled
alpha
login
or
join now
pyrox.dev
/
nixpkgs
lol
0
fork
atom
overview
issues
pulls
pipelines
nixosTests.installed-tests.power-profiles-daemon: init
Jan Tojnar
4 years ago
bb9ea676
6e64f03c
+103
-2
4 changed files
expand all
collapse all
unified
split
nixos
tests
installed-tests
default.nix
power-profiles-daemon.nix
pkgs
os-specific
linux
power-profiles-daemon
default.nix
installed-tests-path.patch
+1
nixos/tests/installed-tests/default.nix
···
104
104
malcontent = callInstalledTest ./malcontent.nix {};
105
105
ostree = callInstalledTest ./ostree.nix {};
106
106
pipewire = callInstalledTest ./pipewire.nix {};
107
107
+
power-profiles-daemon = callInstalledTest ./power-profiles-daemon.nix {};
107
108
xdg-desktop-portal = callInstalledTest ./xdg-desktop-portal.nix {};
108
109
}
+9
nixos/tests/installed-tests/power-profiles-daemon.nix
···
1
1
+
{ pkgs, lib, makeInstalledTest, ... }:
2
2
+
3
3
+
makeInstalledTest {
4
4
+
tested = pkgs.power-profiles-daemon;
5
5
+
6
6
+
testConfig = {
7
7
+
services.power-profiles-daemon.enable = true;
8
8
+
};
9
9
+
}
+56
-2
pkgs/os-specific/linux/power-profiles-daemon/default.nix
···
4
4
, meson
5
5
, ninja
6
6
, fetchFromGitLab
7
7
+
, fetchpatch
7
8
, libgudev
8
9
, glib
9
10
, polkit
···
15
16
, libxml2
16
17
, libxslt
17
18
, upower
19
19
+
, umockdev
18
20
, systemd
19
21
, python3
20
22
, wrapGAppsNoGuiHook
21
23
, nixosTests
22
24
}:
23
25
26
26
+
let
27
27
+
testPythonPkgs = ps: with ps; [
28
28
+
pygobject3
29
29
+
dbus-python
30
30
+
python-dbusmock
31
31
+
];
32
32
+
testTypelibPath = lib.makeSearchPathOutput "lib" "lib/girepository-1.0" [ umockdev ];
33
33
+
in
24
34
stdenv.mkDerivation rec {
25
35
pname = "power-profiles-daemon";
26
36
version = "0.10.1";
27
37
28
28
-
outputs = [ "out" "devdoc" ];
38
38
+
outputs = [ "out" "devdoc" "installedTests" ];
29
39
30
40
src = fetchFromGitLab {
31
41
domain = "gitlab.freedesktop.org";
···
35
45
sha256 = "sha256-sQWiCHc0kEELdmPq9Qdk7OKDUgbM5R44639feC7gjJc=";
36
46
};
37
47
48
48
+
patches = [
49
49
+
# Enable installed tests.
50
50
+
# https://gitlab.freedesktop.org/hadess/power-profiles-daemon/-/merge_requests/92
51
51
+
(fetchpatch {
52
52
+
url = "https://gitlab.freedesktop.org/hadess/power-profiles-daemon/-/commit/3c64d9e1732eb6425e33013c452f1c4aa7a26f7e.patch";
53
53
+
sha256 = "din5VuZZwARNDInHtl44yJK8pLmlxr5eoD4iMT4a8HA=";
54
54
+
})
55
55
+
56
56
+
# Install installed tests to separate output.
57
57
+
./installed-tests-path.patch
58
58
+
];
59
59
+
38
60
nativeBuildInputs = [
39
61
pkg-config
40
62
meson
···
46
68
libxml2 # for xmllint for stripping GResources
47
69
libxslt # for xsltproc for building docs
48
70
gobject-introspection
49
49
-
python3
50
71
wrapGAppsNoGuiHook
51
72
python3.pkgs.wrapPython
73
73
+
74
74
+
# For finding tests.
75
75
+
(python3.withPackages testPythonPkgs)
52
76
];
53
77
54
78
buildInputs = [
···
68
92
];
69
93
70
94
mesonFlags = [
95
95
+
"-Dinstalled_test_prefix=${placeholder "installedTests"}"
71
96
"-Dsystemdsystemunitdir=${placeholder "out"}/lib/systemd/system"
72
97
"-Dgtk_doc=true"
73
98
];
···
81
106
patchShebangs tests/unittest_inspector.py
82
107
'';
83
108
109
109
+
preConfigure = ''
110
110
+
# For finding tests.
111
111
+
GI_TYPELIB_PATH_original=$GI_TYPELIB_PATH
112
112
+
addToSearchPath GI_TYPELIB_PATH "${testTypelibPath}"
113
113
+
'';
114
114
+
115
115
+
postConfigure = ''
116
116
+
# Restore the original value to prevent the program from depending on umockdev.
117
117
+
export GI_TYPELIB_PATH=$GI_TYPELIB_PATH_original
118
118
+
unset GI_TYPELIB_PATH_original
119
119
+
'';
120
120
+
84
121
preInstall = ''
85
122
# We have pkexec on PATH so Meson will try to use it when installation fails
86
123
# due to being unable to write to e.g. /etc.
···
96
133
makeWrapperArgs+=("''${gappsWrapperArgs[@]}")
97
134
# Make Python libraries available
98
135
wrapPythonProgramsIn "$out/bin" "$pythonPath"
136
136
+
137
137
+
# Make Python libraries available for installed tests
138
138
+
makeWrapperArgs+=(
139
139
+
--prefix GI_TYPELIB_PATH : "${testTypelibPath}"
140
140
+
--prefix PATH : "${lib.makeBinPath [ umockdev ]}"
141
141
+
# Vala does not use absolute paths in typelibs
142
142
+
# https://github.com/NixOS/nixpkgs/issues/47226
143
143
+
# Also umockdev binaries use relative paths for LD_PRELOAD.
144
144
+
--prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath [ umockdev ]}"
145
145
+
# dbusmock calls its templates using exec so our regular patching of Python scripts
146
146
+
# to add package directories to site will not carry over.
147
147
+
# https://github.com/martinpitt/python-dbusmock/blob/2254e69279a02fb3027b500ed7288b77c7a80f2a/dbusmock/mockobject.py#L51
148
148
+
# https://github.com/martinpitt/python-dbusmock/blob/2254e69279a02fb3027b500ed7288b77c7a80f2a/dbusmock/__main__.py#L60-L62
149
149
+
--prefix PYTHONPATH : "${lib.makeSearchPath python3.sitePackages (testPythonPkgs python3.pkgs)}"
150
150
+
)
151
151
+
wrapPythonProgramsIn "$installedTests/libexec/installed-tests" "$pythonPath ${lib.concatStringsSep " " (testPythonPkgs python3.pkgs)}"
99
152
'';
100
153
101
154
passthru = {
102
155
tests = {
103
156
nixos = nixosTests.power-profiles-daemon;
157
157
+
installed-tests = nixosTests.installed-tests.power-profiles-daemon;
104
158
};
105
159
};
106
160
+37
pkgs/os-specific/linux/power-profiles-daemon/installed-tests-path.patch
···
1
1
+
diff --git a/meson_options.txt b/meson_options.txt
2
2
+
index 7e89619..76497db 100644
3
3
+
--- a/meson_options.txt
4
4
+
+++ b/meson_options.txt
5
5
+
@@ -1,3 +1,4 @@
6
6
+
+option('installed_test_prefix', type: 'string', description: 'Prefix for installed tests')
7
7
+
option('systemdsystemunitdir',
8
8
+
description: 'systemd unit directory',
9
9
+
type: 'string',
10
10
+
diff --git a/tests/meson.build b/tests/meson.build
11
11
+
index b306a7f..7670e1b 100644
12
12
+
--- a/tests/meson.build
13
13
+
+++ b/tests/meson.build
14
14
+
@@ -2,8 +2,8 @@ envs = environment()
15
15
+
envs.set ('top_builddir', meson.build_root())
16
16
+
envs.set ('top_srcdir', meson.source_root())
17
17
+
18
18
+
-installed_test_bindir = libexecdir / 'installed-tests' / meson.project_name()
19
19
+
-installed_test_datadir = datadir / 'installed-tests' / meson.project_name()
20
20
+
+installed_test_bindir = get_option('installed_test_prefix') / 'libexec' / 'installed-tests' / meson.project_name()
21
21
+
+installed_test_datadir = get_option('installed_test_prefix') / 'share' / 'installed-tests' / meson.project_name()
22
22
+
23
23
+
python3 = find_program('python3')
24
24
+
unittest_inspector = find_program('unittest_inspector.py')
25
25
+
diff --git a/tests/integration-test.py b/tests/integration-test.py
26
26
+
index 22dc42c..0f92b76 100755
27
27
+
--- a/tests/integration-test.py
28
28
+
+++ b/tests/integration-test.py
29
29
+
@@ -67,7 +67,7 @@ class Tests(dbusmock.DBusTestCase):
30
30
+
print('Testing binaries from JHBuild (%s)' % cls.daemon_path)
31
31
+
else:
32
32
+
cls.daemon_path = None
33
33
+
- with open('/usr/lib/systemd/system/power-profiles-daemon.service') as f:
34
34
+
+ with open('/run/current-system/sw/lib/systemd/system/power-profiles-daemon.service') as f:
35
35
+
for line in f:
36
36
+
if line.startswith('ExecStart='):
37
37
+
cls.daemon_path = line.split('=', 1)[1].strip()