nixos/modules/power-management.nix

33 lines
835 B
Nix
Raw Permalink Normal View History

{
pkgs,
lib,
config,
...
}: let
cfg = config.services.power;
in {
options.services.power = {
target.enable = lib.mkEnableOption "power management through some controller";
};
config = lib.mkIf cfg.target.enable {
users.users.power-target = {
isNormalUser = true;
openssh.authorizedKeys.keyFiles = [../secrets/pub/yubikey.pub ../secrets/pub/power-management-key.pub];
group = "power-target";
2024-11-17 18:09:11 +01:00
packages = [pkgs.pmutils];
};
users.groups.power-target = {};
security.sudo.extraRules = lib.mkAfter [
{
2024-11-17 18:09:11 +01:00
users = [config.users.users.power-target.name];
commands = lib.singleton {
command = "/etc/profiles/per-user/${config.users.users.power-target.name}/bin/pm-suspend";
options = lib.singleton "NOPASSWD";
};
}
];
};
}