summaryrefslogtreecommitdiffstats
path: root/nixos/modules/services/desktops/dunst.nix
blob: 5713a300347e5a28ec0e2d00617f8ba02555303a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
{
  config,
  pkgs,
  lib,
  ...
}:
let
  gitIni = pkgs.formats.gitIni { };
  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 = gitIni.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 = gitIni.generate "dunstrc" cfg.settings;
    };

    services.dbus.packages = [ cfg.package ];
  };

  meta.maintainers = with lib.maintainers; [ nyukuru ];
}