Merge pull request #289748 from picnoir/pic/ppd020

power-profiles-daemon: 0.13 -> 0.20
This commit is contained in:
K900 2024-02-24 12:30:49 +03:00 committed by GitHub
commit f5c4b5837d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 27 additions and 33 deletions

View file

@ -8,22 +8,22 @@ import ./make-test-python.nix ({ pkgs, ... }:
nodes.machine = { pkgs, ... }: { nodes.machine = { pkgs, ... }: {
security.polkit.enable = true; security.polkit.enable = true;
services.power-profiles-daemon.enable = true; services.power-profiles-daemon.enable = true;
environment.systemPackages = [ pkgs.glib ]; environment.systemPackages = [ pkgs.glib pkgs.power-profiles-daemon ];
}; };
testScript = '' testScript = ''
def get_profile(): def get_profile():
return machine.succeed( return machine.succeed(
"""gdbus call --system --dest net.hadess.PowerProfiles --object-path /net/hadess/PowerProfiles \ """gdbus call --system --dest org.freedesktop.UPower.PowerProfiles --object-path /org/freedesktop/UPower/PowerProfiles \
--method org.freedesktop.DBus.Properties.Get 'net.hadess.PowerProfiles' 'ActiveProfile' --method org.freedesktop.DBus.Properties.Get 'org.freedesktop.UPower.PowerProfiles' 'ActiveProfile'
""" """
) )
def set_profile(profile): def set_profile(profile):
return machine.succeed( return machine.succeed(
"""gdbus call --system --dest net.hadess.PowerProfiles --object-path /net/hadess/PowerProfiles \ """gdbus call --system --dest org.freedesktop.UPower.PowerProfiles --object-path /org/freedesktop/UPower/PowerProfiles \
--method org.freedesktop.DBus.Properties.Set 'net.hadess.PowerProfiles' 'ActiveProfile' "<'{profile}'>" --method org.freedesktop.DBus.Properties.Set 'org.freedesktop.UPower.PowerProfiles' 'ActiveProfile' "<'{profile}'>"
""".format( """.format(
profile=profile profile=profile
) )
@ -42,5 +42,16 @@ import ./make-test-python.nix ({ pkgs, ... }:
profile = get_profile() profile = get_profile()
if not "balanced" in profile: if not "balanced" in profile:
raise Exception("Unable to set balanced profile") raise Exception("Unable to set balanced profile")
# test powerprofilectl CLI
machine.succeed("powerprofilesctl set power-saver")
profile = get_profile()
if not "power-saver" in profile:
raise Exception("Unable to set power-saver profile with powerprofilectl")
machine.succeed("powerprofilesctl set balanced")
profile = get_profile()
if not "balanced" in profile:
raise Exception("Unable to set balanced profile with powerprofilectl")
''; '';
}) })

View file

@ -5,7 +5,6 @@
, mesonEmulatorHook , mesonEmulatorHook
, ninja , ninja
, fetchFromGitLab , fetchFromGitLab
, fetchpatch
, libgudev , libgudev
, glib , glib
, polkit , polkit
@ -21,22 +20,21 @@
, umockdev , umockdev
, systemd , systemd
, python3 , python3
, wrapGAppsNoGuiHook
, nixosTests , nixosTests
}: }:
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
pname = "power-profiles-daemon"; pname = "power-profiles-daemon";
version = "0.13"; version = "0.20";
outputs = [ "out" "devdoc" ]; outputs = [ "out" "devdoc" ];
src = fetchFromGitLab { src = fetchFromGitLab {
domain = "gitlab.freedesktop.org"; domain = "gitlab.freedesktop.org";
owner = "hadess"; owner = "upower";
repo = "power-profiles-daemon"; repo = "power-profiles-daemon";
rev = version; rev = version;
sha256 = "sha256-ErHy+shxZQ/aCryGhovmJ6KmAMt9OZeQGDbHIkC0vUE="; sha256 = "sha256-8wSRPR/1ELcsZ9K3LvSNlPcJvxRhb/LRjTIxKtdQlCA=";
}; };
nativeBuildInputs = [ nativeBuildInputs = [
@ -50,8 +48,6 @@ stdenv.mkDerivation rec {
libxml2 # for xmllint for stripping GResources libxml2 # for xmllint for stripping GResources
libxslt # for xsltproc for building docs libxslt # for xsltproc for building docs
gobject-introspection gobject-introspection
wrapGAppsNoGuiHook
python3.pkgs.wrapPython
# checkInput but cheked for during the configuring # checkInput but cheked for during the configuring
(python3.pythonOnBuildForHost.withPackages (ps: with ps; [ (python3.pythonOnBuildForHost.withPackages (ps: with ps; [
pygobject3 pygobject3
@ -68,16 +64,16 @@ stdenv.mkDerivation rec {
upower upower
glib glib
polkit polkit
python3 # for cli tool # for cli tool
# Duplicate from nativeCheckInputs until https://github.com/NixOS/nixpkgs/issues/161570 is solved (python3.withPackages (ps: [
umockdev ps.pygobject3
]))
]; ];
strictDeps = true; strictDeps = true;
# for cli tool checkInputs = [
pythonPath = [ umockdev
python3.pkgs.pygobject3
]; ];
nativeCheckInputs = [ nativeCheckInputs = [
@ -95,26 +91,13 @@ stdenv.mkDerivation rec {
PKG_CONFIG_POLKIT_GOBJECT_1_POLICYDIR = "${placeholder "out"}/share/polkit-1/actions"; PKG_CONFIG_POLKIT_GOBJECT_1_POLICYDIR = "${placeholder "out"}/share/polkit-1/actions";
# Avoid double wrapping
dontWrapGApps = true;
postPatch = '' postPatch = ''
patchShebangs --build \ patchShebangs --build \
tests/integration-test.py \ tests/integration-test.py \
tests/unittest_inspector.py tests/unittest_inspector.py
'';
postCheck = '' patchShebangs --host \
# Do not contaminate the wrapper with test dependencies. src/powerprofilesctl
unset GI_TYPELIB_PATH
unset XDG_DATA_DIRS
'';
postFixup = ''
# Avoid double wrapping
makeWrapperArgs+=("''${gappsWrapperArgs[@]}")
# Make Python libraries available
wrapPythonProgramsIn "$out/bin" "$pythonPath"
''; '';
passthru = { passthru = {