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}"}"; + }; + }; + }; +}