From 1da5ce612e770050beace8ef66b613d8a9d01290 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Schr=C3=B6ter?= Date: Fri, 6 Jan 2023 19:03:57 +0100 Subject: [PATCH] feat: expand systemd notify service with libnotify option --- flake.nix | 2 +- home-pc.nix | 10 ++-- home-server.nix | 12 +++-- modules/emailNotify.nix | 67 ----------------------- modules/systemdNotify.nix | 108 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 120 insertions(+), 79 deletions(-) delete mode 100644 modules/emailNotify.nix create mode 100644 modules/systemdNotify.nix diff --git a/flake.nix b/flake.nix index 8b18120..ee3cf03 100644 --- a/flake.nix +++ b/flake.nix @@ -68,7 +68,7 @@ }; nixosModules = { flakeDefaults = import ./modules/flakeDefaults.nix; - emailNotify = import ./modules/emailNotify.nix; + systemdNotify = import ./modules/systemdNotify.nix; }; homeManagerModules = { git = import ./home/modules/git.nix; }; systemDefaults = { diff --git a/home-pc.nix b/home-pc.nix index 7fdd34f..61102ca 100644 --- a/home-pc.nix +++ b/home-pc.nix @@ -12,8 +12,7 @@ ./desktop ./virtualisation/libvirt.nix ./virtualisation/podman.nix - ./modules/emailNotify.nix - ./services/mail.nix + ./modules/systemdNotify.nix ./services/samba/home-pc.nix ./services/restic/home-pc.nix ./services/pcscd.nix @@ -52,10 +51,9 @@ "87.98.162.88" = [ "portcheck.transmissionbt.com" ]; }; - systemd.emailNotify.enable = true; - systemd.emailNotify.mailTo = "admin@felschr.com"; - systemd.emailNotify.mailFrom = - "${config.networking.hostName} "; + systemd.notify.enable = true; + systemd.notify.method = "libnotify"; + systemd.notify.libnotify.user = "felschr"; services.printing.drivers = with pkgs; [ epson-escpr ]; diff --git a/home-server.nix b/home-server.nix index d49b1cc..d5d36a6 100644 --- a/home-server.nix +++ b/home-server.nix @@ -14,7 +14,7 @@ in with builtins; { ./hardware/gpu-intel.nix ./desktop/x11.nix ./system/server.nix - ./modules/emailNotify.nix + ./modules/systemdNotify.nix ./services/mail.nix ./services/restic/home-server.nix ./services/samba/home-server.nix @@ -134,10 +134,12 @@ in with builtins; { }; }; - systemd.emailNotify.enable = true; - systemd.emailNotify.mailTo = "admin@felschr.com"; - systemd.emailNotify.mailFrom = - "${config.networking.hostName} "; + systemd.notify = { + enable = true; + method = "email"; + email.mailTo = "admin@felschr.com"; + email.mailFrom = "${config.networking.hostName} "; + }; # only change this when specified in release notes system.stateVersion = "22.11"; diff --git a/modules/emailNotify.nix b/modules/emailNotify.nix deleted file mode 100644 index a46e8c2..0000000 --- a/modules/emailNotify.nix +++ /dev/null @@ -1,67 +0,0 @@ -{ config, lib, pkgs, ... }: - -with lib; - -let - cfg = config.systemd.emailNotify; - sendmail = pkgs.writeScript "sendmail" '' - #!${pkgs.runtimeShell} - - ${pkgs.system-sendmail}/bin/sendmail -t <