From 94be83c7043a6b36fb00c590baf33eb66f600cf9 Mon Sep 17 00:00:00 2001 From: xeals Date: Sat, 13 Nov 2021 18:52:41 +1100 Subject: [PATCH] modules/dunst: init --- modules/default.nix | 1 + modules/services/x11/dunst.nix | 71 ++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 modules/services/x11/dunst.nix diff --git a/modules/default.nix b/modules/default.nix index 5263bd7..905a61d 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -2,6 +2,7 @@ amdgpu-common = ./services/hardware/amdgpu-common.nix; amdgpu-fan = ./services/hardware/amdgpu-fan.nix; amdgpu-pwm = ./services/hardware/amdgpu-pwm.nix; + dunst = ./services/x11/dunst.nix; radeon-profile-daemon = ./services/hardware/radeon-profile-daemon.nix; } diff --git a/modules/services/x11/dunst.nix b/modules/services/x11/dunst.nix new file mode 100644 index 0000000..55e1428 --- /dev/null +++ b/modules/services/x11/dunst.nix @@ -0,0 +1,71 @@ +{ config, lib, pkgs, ... }: + +with lib; +let + cfg = config.services.dunst; +in +{ + options.services.dunst = { + enable = mkEnableOption "dunst"; + + package = mkOption { + type = types.package; + default = pkgs.dunst; + }; + + settings = mkOption { + type = types.nullOr types.attrs; + default = null; + description = '' + Configuration set alternative to + configFile. + ''; + example = '' + { + global = { + monitor = 0; + follow = "none"; + }; + }; + ''; + }; + + configFile = mkOption { + type = types.nullOr types.path; + default = null; + description = "Path to dunstrc configuration file."; + }; + }; + + config = mkIf cfg.enable { + assertions = [ + { + assertion = !(cfg.settings != null && cfg.configFile != null); + message = "only one of services.dunst.settings or .configFile may be specified"; + } + ]; + + environment.systemPackages = [ (getOutput "man" cfg.package) ]; + + systemd.user.services.dunst = { + description = "Dunst notification daemon"; + documentation = [ "man:dunst(1)" ]; + after = [ "graphical-session-pre.target" ]; + partOf = [ "graphical-session.target" ]; + serviceConfig = { + Type = "dbus"; + BusName = "org.freedesktop.Notifications"; + ExecStart = + let + config = + if (cfg.settings != null) + then pkgs.writeText "dunstrc" (generators.toINI { } cfg.settings) + else if (cfg.configFile != null) + then cfg.configFile + else null; + in + "${cfg.package}/bin/dunst ${optionalString (config != null) "-conf ${config}"}"; + }; + }; + }; +}