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