2020-09-14 11:49:42 +01:00
|
|
|
|
{ stdenv
|
|
|
|
|
, lib
|
|
|
|
|
, pkg-config
|
|
|
|
|
, meson
|
|
|
|
|
, ninja
|
|
|
|
|
, fetchFromGitLab
|
2021-10-29 08:14:33 +01:00
|
|
|
|
, fetchpatch
|
2020-09-14 11:49:42 +01:00
|
|
|
|
, libgudev
|
|
|
|
|
, glib
|
2021-10-29 04:31:43 +01:00
|
|
|
|
, polkit
|
2020-09-14 11:49:42 +01:00
|
|
|
|
, gobject-introspection
|
|
|
|
|
, gettext
|
|
|
|
|
, gtk-doc
|
|
|
|
|
, docbook-xsl-nons
|
|
|
|
|
, docbook_xml_dtd_412
|
|
|
|
|
, libxml2
|
|
|
|
|
, libxslt
|
|
|
|
|
, upower
|
2021-10-29 08:14:33 +01:00
|
|
|
|
, umockdev
|
2020-09-14 11:49:42 +01:00
|
|
|
|
, systemd
|
2021-04-05 09:04:44 +01:00
|
|
|
|
, python3
|
2021-10-29 04:31:43 +01:00
|
|
|
|
, wrapGAppsNoGuiHook
|
2021-10-29 05:15:27 +01:00
|
|
|
|
, nixosTests
|
2020-09-14 11:49:42 +01:00
|
|
|
|
}:
|
|
|
|
|
|
2021-10-29 08:14:33 +01:00
|
|
|
|
let
|
|
|
|
|
testPythonPkgs = ps: with ps; [
|
|
|
|
|
pygobject3
|
|
|
|
|
dbus-python
|
|
|
|
|
python-dbusmock
|
|
|
|
|
];
|
|
|
|
|
testTypelibPath = lib.makeSearchPathOutput "lib" "lib/girepository-1.0" [ umockdev ];
|
|
|
|
|
in
|
2020-09-14 11:49:42 +01:00
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
|
pname = "power-profiles-daemon";
|
2021-10-29 04:31:43 +01:00
|
|
|
|
version = "0.10.1";
|
2020-09-14 11:49:42 +01:00
|
|
|
|
|
2021-10-29 08:14:33 +01:00
|
|
|
|
outputs = [ "out" "devdoc" "installedTests" ];
|
2020-09-14 11:49:42 +01:00
|
|
|
|
|
|
|
|
|
src = fetchFromGitLab {
|
|
|
|
|
domain = "gitlab.freedesktop.org";
|
|
|
|
|
owner = "hadess";
|
|
|
|
|
repo = "power-profiles-daemon";
|
|
|
|
|
rev = version;
|
2021-10-29 04:31:43 +01:00
|
|
|
|
sha256 = "sha256-sQWiCHc0kEELdmPq9Qdk7OKDUgbM5R44639feC7gjJc=";
|
2020-09-14 11:49:42 +01:00
|
|
|
|
};
|
|
|
|
|
|
2021-10-29 08:14:33 +01:00
|
|
|
|
patches = [
|
|
|
|
|
# Enable installed tests.
|
|
|
|
|
# https://gitlab.freedesktop.org/hadess/power-profiles-daemon/-/merge_requests/92
|
|
|
|
|
(fetchpatch {
|
|
|
|
|
url = "https://gitlab.freedesktop.org/hadess/power-profiles-daemon/-/commit/3c64d9e1732eb6425e33013c452f1c4aa7a26f7e.patch";
|
|
|
|
|
sha256 = "din5VuZZwARNDInHtl44yJK8pLmlxr5eoD4iMT4a8HA=";
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
# Install installed tests to separate output.
|
|
|
|
|
./installed-tests-path.patch
|
|
|
|
|
];
|
|
|
|
|
|
2020-09-14 11:49:42 +01:00
|
|
|
|
nativeBuildInputs = [
|
|
|
|
|
pkg-config
|
|
|
|
|
meson
|
|
|
|
|
ninja
|
|
|
|
|
gettext
|
|
|
|
|
gtk-doc
|
|
|
|
|
docbook-xsl-nons
|
|
|
|
|
docbook_xml_dtd_412
|
|
|
|
|
libxml2 # for xmllint for stripping GResources
|
|
|
|
|
libxslt # for xsltproc for building docs
|
|
|
|
|
gobject-introspection
|
2021-10-29 04:31:43 +01:00
|
|
|
|
wrapGAppsNoGuiHook
|
|
|
|
|
python3.pkgs.wrapPython
|
2021-10-29 08:14:33 +01:00
|
|
|
|
|
|
|
|
|
# For finding tests.
|
|
|
|
|
(python3.withPackages testPythonPkgs)
|
2020-09-14 11:49:42 +01:00
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
buildInputs = [
|
|
|
|
|
libgudev
|
|
|
|
|
systemd
|
|
|
|
|
upower
|
|
|
|
|
glib
|
2021-10-29 04:31:43 +01:00
|
|
|
|
polkit
|
|
|
|
|
python3 # for cli tool
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
strictDeps = true;
|
|
|
|
|
|
|
|
|
|
# for cli tool
|
|
|
|
|
pythonPath = [
|
|
|
|
|
python3.pkgs.pygobject3
|
2020-09-14 11:49:42 +01:00
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
mesonFlags = [
|
2021-10-29 08:14:33 +01:00
|
|
|
|
"-Dinstalled_test_prefix=${placeholder "installedTests"}"
|
2020-09-14 11:49:42 +01:00
|
|
|
|
"-Dsystemdsystemunitdir=${placeholder "out"}/lib/systemd/system"
|
|
|
|
|
"-Dgtk_doc=true"
|
|
|
|
|
];
|
|
|
|
|
|
2021-10-29 04:31:43 +01:00
|
|
|
|
PKG_CONFIG_POLKIT_GOBJECT_1_POLICYDIR = "${placeholder "out"}/share/polkit-1/actions";
|
|
|
|
|
|
|
|
|
|
# Avoid double wrapping
|
|
|
|
|
dontWrapGApps = true;
|
|
|
|
|
|
|
|
|
|
postPatch = ''
|
|
|
|
|
patchShebangs tests/unittest_inspector.py
|
|
|
|
|
'';
|
|
|
|
|
|
2021-10-29 08:14:33 +01:00
|
|
|
|
preConfigure = ''
|
|
|
|
|
# For finding tests.
|
|
|
|
|
GI_TYPELIB_PATH_original=$GI_TYPELIB_PATH
|
|
|
|
|
addToSearchPath GI_TYPELIB_PATH "${testTypelibPath}"
|
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
postConfigure = ''
|
|
|
|
|
# Restore the original value to prevent the program from depending on umockdev.
|
|
|
|
|
export GI_TYPELIB_PATH=$GI_TYPELIB_PATH_original
|
|
|
|
|
unset GI_TYPELIB_PATH_original
|
|
|
|
|
'';
|
|
|
|
|
|
2021-10-29 04:31:43 +01:00
|
|
|
|
preInstall = ''
|
|
|
|
|
# We have pkexec on PATH so Meson will try to use it when installation fails
|
|
|
|
|
# due to being unable to write to e.g. /etc.
|
|
|
|
|
# Let’s pretend we already ran pkexec –
|
|
|
|
|
# the pkexec on PATH would complain it lacks setuid bit,
|
|
|
|
|
# obscuring the underlying error.
|
|
|
|
|
# https://github.com/mesonbuild/meson/blob/492cc9bf95d573e037155b588dc5110ded4d9a35/mesonbuild/minstall.py#L558
|
|
|
|
|
export PKEXEC_UID=-1
|
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
postFixup = ''
|
|
|
|
|
# Avoid double wrapping
|
|
|
|
|
makeWrapperArgs+=("''${gappsWrapperArgs[@]}")
|
|
|
|
|
# Make Python libraries available
|
|
|
|
|
wrapPythonProgramsIn "$out/bin" "$pythonPath"
|
2021-10-29 08:14:33 +01:00
|
|
|
|
|
|
|
|
|
# Make Python libraries available for installed tests
|
|
|
|
|
makeWrapperArgs+=(
|
|
|
|
|
--prefix GI_TYPELIB_PATH : "${testTypelibPath}"
|
|
|
|
|
--prefix PATH : "${lib.makeBinPath [ umockdev ]}"
|
|
|
|
|
# Vala does not use absolute paths in typelibs
|
|
|
|
|
# https://github.com/NixOS/nixpkgs/issues/47226
|
|
|
|
|
# Also umockdev binaries use relative paths for LD_PRELOAD.
|
|
|
|
|
--prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath [ umockdev ]}"
|
|
|
|
|
# dbusmock calls its templates using exec so our regular patching of Python scripts
|
|
|
|
|
# to add package directories to site will not carry over.
|
|
|
|
|
# https://github.com/martinpitt/python-dbusmock/blob/2254e69279a02fb3027b500ed7288b77c7a80f2a/dbusmock/mockobject.py#L51
|
|
|
|
|
# https://github.com/martinpitt/python-dbusmock/blob/2254e69279a02fb3027b500ed7288b77c7a80f2a/dbusmock/__main__.py#L60-L62
|
|
|
|
|
--prefix PYTHONPATH : "${lib.makeSearchPath python3.sitePackages (testPythonPkgs python3.pkgs)}"
|
|
|
|
|
)
|
|
|
|
|
wrapPythonProgramsIn "$installedTests/libexec/installed-tests" "$pythonPath ${lib.concatStringsSep " " (testPythonPkgs python3.pkgs)}"
|
2021-10-29 04:31:43 +01:00
|
|
|
|
'';
|
|
|
|
|
|
2021-10-29 05:15:27 +01:00
|
|
|
|
passthru = {
|
|
|
|
|
tests = {
|
|
|
|
|
nixos = nixosTests.power-profiles-daemon;
|
2021-10-29 08:14:33 +01:00
|
|
|
|
installed-tests = nixosTests.installed-tests.power-profiles-daemon;
|
2021-10-29 05:15:27 +01:00
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2020-09-14 11:49:42 +01:00
|
|
|
|
meta = with lib; {
|
|
|
|
|
homepage = "https://gitlab.freedesktop.org/hadess/power-profiles-daemon";
|
|
|
|
|
description = "Makes user-selected power profiles handling available over D-Bus";
|
|
|
|
|
platforms = platforms.linux;
|
|
|
|
|
license = licenses.gpl3Plus;
|
2021-10-29 04:31:43 +01:00
|
|
|
|
maintainers = with maintainers; [ jtojnar mvnetbiz ];
|
2020-09-14 11:49:42 +01:00
|
|
|
|
};
|
|
|
|
|
}
|