diff --git a/nixos/doc/manual/release-notes/rl-2605.section.md b/nixos/doc/manual/release-notes/rl-2605.section.md index dea390ae8dfc..a9385ccb445c 100644 --- a/nixos/doc/manual/release-notes/rl-2605.section.md +++ b/nixos/doc/manual/release-notes/rl-2605.section.md @@ -36,6 +36,8 @@ - [dsearch](https://github.com/AvengeMedia/danksearch), a fast filesystem search service with fuzzy matching. Available as [programs.dsearch](#opt-programs.dsearch.enable). +- [Dunst](https://github.com/dunst-project/dunst), a lightweight and customizable notification daemon. Available as [services.dunst](#opt-services.dunst.enable). + - [Ente Auth](https://ente.io/auth/), an open source 2FA authenticator, with end-to-end encrypted backups. Available as [programs.ente-auth](#opt-programs.ente-auth.enable). - [Dawarich](https://dawarich.app/), a self-hostable location history tracker. Available as [services.dawarich](#opt-services.dawarich.enable). diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index a6913729e510..4539b49f7ba8 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -558,6 +558,7 @@ ./services/desktops/bonsaid.nix ./services/desktops/cpupower-gui.nix ./services/desktops/dleyna.nix + ./services/desktops/dunst.nix ./services/desktops/espanso.nix ./services/desktops/flatpak.nix ./services/desktops/geoclue2.nix diff --git a/nixos/modules/services/desktops/dunst.nix b/nixos/modules/services/desktops/dunst.nix new file mode 100644 index 000000000000..a1198f828021 --- /dev/null +++ b/nixos/modules/services/desktops/dunst.nix @@ -0,0 +1,79 @@ +{ + config, + pkgs, + lib, + ... +}: +let + toml = pkgs.formats.toml { }; + cfg = config.services.dunst; +in +{ + options.services.dunst = { + enable = lib.mkEnableOption "Dunst notification daemon"; + + package = lib.mkPackageOption pkgs "dunst" { } // { + apply = + p: + p.override { + withX11 = cfg.enableX11; + withWayland = cfg.enableWayland; + }; + }; + + settings = lib.mkOption { + type = toml.type; + default = { }; + description = "Dunst configuration, see dunst(5)"; + example = lib.literalExpression '' + { + global = { + width = 300; + height = 300; + offset = "30x50"; + origin = "top-right"; + transparency = 10; + frame_color = "#eceff1"; + font = "Droid Sans 9"; + }; + + urgency_normal = { + background = "#37474f"; + foreground = "#eceff1"; + timeout = 10; + }; + }; + ''; + }; + + enableX11 = lib.mkOption { + type = lib.types.bool; + default = true; + description = "Whether to enable X11 support."; + }; + + enableWayland = lib.mkOption { + type = lib.types.bool; + default = true; + description = "Whether to enable Wayland support."; + }; + }; + + config = lib.mkIf cfg.enable { + assertions = [ + { + assertion = cfg.enableX11 || cfg.enableWayland; + message = "Dunst must be built with at least either X11 support or Wayland support"; + } + ]; + + environment = { + systemPackages = [ cfg.package ]; + etc."xdg/dunst/dunstrc".source = toml.generate "dunstrc" cfg.settings; + }; + + services.dbus.packages = [ cfg.package ]; + }; + + meta.maintainers = with lib.maintainers; [ nyukuru ]; +} diff --git a/pkgs/by-name/du/dunst/package.nix b/pkgs/by-name/du/dunst/package.nix index edcdae052fde..e84968bd3b57 100644 --- a/pkgs/by-name/du/dunst/package.nix +++ b/pkgs/by-name/du/dunst/package.nix @@ -77,7 +77,8 @@ stdenv.mkDerivation (finalAttrs: { makeFlags = [ "PREFIX=$(out)" "VERSION=$(version)" - "SYSCONFDIR=$(out)/etc" + "SYSCONFDIR=/etc/xdg" + "SYSCONF_FORCE_NEW=0" "SERVICEDIR_DBUS=$(out)/share/dbus-1/services" "SERVICEDIR_SYSTEMD=$(out)/lib/systemd/user" ]