From 865e404826a802b38de33e5465cea510f8eca15a Mon Sep 17 00:00:00 2001 From: Thibaut Marty Date: Tue, 27 Apr 2021 22:38:41 +0200 Subject: [PATCH] poweralertd: add module (#1951) --- .github/CODEOWNERS | 2 ++ modules/misc/news.nix | 8 ++++++++ modules/modules.nix | 1 + modules/services/poweralertd.nix | 31 +++++++++++++++++++++++++++++++ 4 files changed, 42 insertions(+) create mode 100644 modules/services/poweralertd.nix diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index bf5690b42..4b72b0fd2 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -225,6 +225,8 @@ /modules/services/playerctld.nix @fendse /tests/modules/playerctld @fendse +/modules/services/poweralertd.nix @ThibautMarty + /modules/services/pulseeffects.nix @jonringer /modules/services/random-background.nix @rycee diff --git a/modules/misc/news.nix b/modules/misc/news.nix index cf32e0a0c..a07efa1fe 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -1906,6 +1906,14 @@ in ''; } + { + time = "2021-04-26T07:00:00+00:00"; + condition = hostPlatform.isLinux; + message = '' + A new service is available: 'services.poweralertd'. + ''; + } + ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index 76e79669f..e9334d1be 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -181,6 +181,7 @@ let (loadModule ./services/plan9port.nix { condition = hostPlatform.isLinux; }) (loadModule ./services/playerctld.nix { condition = hostPlatform.isLinux; }) (loadModule ./services/polybar.nix { }) + (loadModule ./services/poweralertd.nix { condition = hostPlatform.isLinux; }) (loadModule ./services/pulseeffects.nix { condition = hostPlatform.isLinux; }) (loadModule ./services/random-background.nix { }) (loadModule ./services/redshift-gammastep/redshift.nix { }) diff --git a/modules/services/poweralertd.nix b/modules/services/poweralertd.nix new file mode 100644 index 000000000..39fffd7cd --- /dev/null +++ b/modules/services/poweralertd.nix @@ -0,0 +1,31 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let cfg = config.services.poweralertd; + +in { + meta.maintainers = [ maintainers.thibautmarty ]; + + options.services.poweralertd.enable = + mkEnableOption "the Upower-powered power alerterd"; + + config = mkIf cfg.enable { + systemd.user.services.poweralertd = { + Unit = { + Description = "UPower-powered power alerter"; + Documentation = "man:poweralertd(1)"; + After = [ "graphical-session-pre.target" ]; + PartOf = [ "graphical-session.target" ]; + }; + + Install.WantedBy = [ "graphical-session.target" ]; + + Service = { + Type = "simple"; + ExecStart = "${pkgs.poweralertd}/bin/poweralertd"; + Restart = "always"; + }; + }; + }; +}