From fe72ea840cce52ff30940fff5d7fd42205e415ab Mon Sep 17 00:00:00 2001 From: Thibaut Marty Date: Fri, 23 Apr 2021 11:02:52 +0200 Subject: [PATCH] poweralertd: add module --- .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 965d56208a6e..4d89d405494c 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -223,6 +223,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 88193c55cb92..5599f357b27c 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -1897,6 +1897,14 @@ in A new module is available: 'programs.exa'. ''; } + + { + 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 952abc1ed06a..41e14d2830db 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -180,6 +180,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 000000000000..39fffd7cdded --- /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"; + }; + }; + }; +}