diff options
-rw-r--r-- | machines/profpatsch/base-workstation.nix | 14 | ||||
-rw-r--r-- | modules/module-list.nix | 1 | ||||
-rw-r--r-- | modules/services/upower-minimal.nix | 84 |
3 files changed, 99 insertions, 0 deletions
diff --git a/machines/profpatsch/base-workstation.nix b/machines/profpatsch/base-workstation.nix index b9e07ee0..a48c18b4 100644 --- a/machines/profpatsch/base-workstation.nix +++ b/machines/profpatsch/base-workstation.nix @@ -47,6 +47,20 @@ in { freeMemThreshold = 5; # <5% free }; + vuizvui.services.upower = { + enable = true; + settings = { + UPower = { + UsePercentageForPolicy = true; + CriticalPowerAction = "Suspend"; + + PercentageLow = 15; + PercentageCritical = 8; + PercentageAction = 5; + }; + }; + }; + ################### # Graphical System diff --git a/modules/module-list.nix b/modules/module-list.nix index 7429c887..39345699 100644 --- a/modules/module-list.nix +++ b/modules/module-list.nix @@ -15,6 +15,7 @@ ./services/postfix ./services/starbound.nix ./services/guix.nix + ./services/upower-minimal.nix ./system/iso.nix ./system/kernel/bfq ./system/kernel/rckernel.nix diff --git a/modules/services/upower-minimal.nix b/modules/services/upower-minimal.nix new file mode 100644 index 00000000..25de830d --- /dev/null +++ b/modules/services/upower-minimal.nix @@ -0,0 +1,84 @@ +# this is the +# Upower daemon. +# module from nixpkgs, but with the option to suspend and less configuration + +{ config, lib, pkgs, ... }: + +let + + cfg = config.vuizvui.services.upower; + + ini = pkgs.formats.ini {}; + + pkg = pkgs.upower.overrideAttrs (old: { + patches = [ + # Adds a "Suspend" action to what to do when the battery is critical + (pkgs.fetchpatch { + url = "https://gitlab.freedesktop.org/upower/upower/-/merge_requests/11.patch"; + sha256 = "sha256-y8ysD+fJIi5SZkWp2n061VBA5cs1EMftOof/h2tvDGo="; + }) + ]; + }); + +in + +{ + + ###### interface + + options = { + + vuizvui.services.upower = { + + enable = lib.mkOption { + type = lib.types.bool; + default = false; + description = '' + Whether to enable Upower, a DBus service that provides power + management support to applications. + ''; + }; + + settings = lib.mkOption { + type = lib.types.nullOr ini.type; + default = null; + description = '' + The upower configuration. + + If null, the default values in <literal>${pkg}/etc/UPower/UPower.conf<literal> are used. + + So far it looks like there is always only one Section called <literal>UPower</literal> + ''; + example = { + UPower = { + TimeCritical = 300; + CriticalPowerAction = "Hibernate"; + }; + }; + }; + + }; + + }; + + + ###### implementation + + config = lib.mkIf cfg.enable { + + + # this is … questionable … l o w e f f o r t + + environment.systemPackages = [ pkg ]; + + services.dbus.packages = [ pkg ]; + + services.udev.packages = [ pkg ]; + + systemd.packages = [ pkg ]; + + environment.etc."UPower/UPower.conf".source = + ini.generate "UPower.conf" cfg.settings; + }; + +} |