about summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authoroxalica <oxalicc@pm.me>2020-05-25 23:13:55 +0800
committerGitHub <noreply@github.com>2020-05-25 10:13:55 -0500
commitfe3e52c29154d8b8549f58dbd296ba373b7b803d (patch)
tree7c708676dadd94e788d2aaf06aabd18401b77919 /nixos
parentf1d9510c991daad405ce17f5a4ca38b2db5146a9 (diff)
downloadnixlib-fe3e52c29154d8b8549f58dbd296ba373b7b803d.tar
nixlib-fe3e52c29154d8b8549f58dbd296ba373b7b803d.tar.gz
nixlib-fe3e52c29154d8b8549f58dbd296ba373b7b803d.tar.bz2
nixlib-fe3e52c29154d8b8549f58dbd296ba373b7b803d.tar.lz
nixlib-fe3e52c29154d8b8549f58dbd296ba373b7b803d.tar.xz
nixlib-fe3e52c29154d8b8549f58dbd296ba373b7b803d.tar.zst
nixlib-fe3e52c29154d8b8549f58dbd296ba373b7b803d.zip
earlyoom: patch absolute dbus path and make nixos module up to date (#88443)
* earlyoom: patch absolute path of dbus-send

* nixos/earlyoom: replace `notificationsCommand` with `enableNotification`

* nixos/earlyoom: setup `systembus-notify` when `enableNotification`
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/services/system/earlyoom.nix23
1 files changed, 19 insertions, 4 deletions
diff --git a/nixos/modules/services/system/earlyoom.nix b/nixos/modules/services/system/earlyoom.nix
index 39d1bf274bd2..c6a001d30eeb 100644
--- a/nixos/modules/services/system/earlyoom.nix
+++ b/nixos/modules/services/system/earlyoom.nix
@@ -67,9 +67,19 @@ in
       notificationsCommand = mkOption {
         type = types.nullOr types.str;
         default = null;
-        example = "sudo -u example_user DISPLAY=:0 DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus notify-send";
         description = ''
-          Command used to send notifications.
+          This option is deprecated and ignored by earlyoom since 1.6.
+          Use <option>services.earlyoom.enableNotifications</option> instead.
+        '';
+      };
+
+      enableNotifications = mkOption {
+        type = types.bool;
+        default = false;
+        description = ''
+          Send notifications about killed processes via the system d-bus.
+          To actually see the notifications in your GUI session, you need to have
+          <literal>systembus-notify</literal> running as your user.
 
           See <link xlink:href="https://github.com/rfjakob/earlyoom#notifications">README</link> for details.
         '';
@@ -87,9 +97,13 @@ in
         message = "Both options in conjunction do not make sense"; }
     ];
 
+    warnings = optional (ecfg.notificationsCommand != null)
+      "`services.earlyoom.notificationsCommand` is deprecated and ignored by earlyoom since 1.6.";
+
     systemd.services.earlyoom = {
       description = "Early OOM Daemon for Linux";
       wantedBy = [ "multi-user.target" ];
+      path = optional ecfg.enableNotifications pkgs.dbus;
       serviceConfig = {
         StandardOutput = "null";
         StandardError = "syslog";
@@ -100,10 +114,11 @@ in
           ${optionalString ecfg.useKernelOOMKiller "-k"} \
           ${optionalString ecfg.ignoreOOMScoreAdjust "-i"} \
           ${optionalString ecfg.enableDebugInfo "-d"} \
-          ${optionalString (ecfg.notificationsCommand != null)
-            "-N ${escapeShellArg ecfg.notificationsCommand}"}
+          ${optionalString ecfg.enableNotifications "-n"}
         '';
       };
     };
+
+    environment.systemPackages = optional ecfg.enableNotifications pkgs.systembus-notify;
   };
 }