mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-24 16:03:23 +00:00
e6c0587ee5
I think this is required for the gdbus invocations used to implement
the test, rather than for power-profiles-daemon itself.
Fixes: a813be071c
("nixos/polkit: don't enable by default")
47 lines
1.3 KiB
Nix
47 lines
1.3 KiB
Nix
import ./make-test-python.nix ({ pkgs, ... }:
|
|
|
|
{
|
|
name = "power-profiles-daemon";
|
|
meta = with pkgs.lib.maintainers; {
|
|
maintainers = [ mvnetbiz ];
|
|
};
|
|
nodes.machine = { pkgs, ... }: {
|
|
security.polkit.enable = true;
|
|
services.power-profiles-daemon.enable = true;
|
|
environment.systemPackages = [ pkgs.glib ];
|
|
};
|
|
|
|
testScript = ''
|
|
def get_profile():
|
|
return machine.succeed(
|
|
"""gdbus call --system --dest net.hadess.PowerProfiles --object-path /net/hadess/PowerProfiles \
|
|
--method org.freedesktop.DBus.Properties.Get 'net.hadess.PowerProfiles' 'ActiveProfile'
|
|
"""
|
|
)
|
|
|
|
|
|
def set_profile(profile):
|
|
return machine.succeed(
|
|
"""gdbus call --system --dest net.hadess.PowerProfiles --object-path /net/hadess/PowerProfiles \
|
|
--method org.freedesktop.DBus.Properties.Set 'net.hadess.PowerProfiles' 'ActiveProfile' "<'{profile}'>"
|
|
""".format(
|
|
profile=profile
|
|
)
|
|
)
|
|
|
|
|
|
machine.wait_for_unit("multi-user.target")
|
|
|
|
set_profile("power-saver")
|
|
profile = get_profile()
|
|
if not "power-saver" in profile:
|
|
raise Exception("Unable to set power-saver profile")
|
|
|
|
|
|
set_profile("balanced")
|
|
profile = get_profile()
|
|
if not "balanced" in profile:
|
|
raise Exception("Unable to set balanced profile")
|
|
'';
|
|
})
|