fork/home-manager

git clone https://git.julia.blue/fork/home-manager

Robert HelgessonMerge PR #421575790441

master
1.7 KiB67 linesraw
1{ config, lib, pkgs, ... }:
2
3with lib;
4
5let
6  cfg = config.wayland.windowManager.sway.swaynag;
7
8  iniFormat = pkgs.formats.ini { };
9
10  confFormat = with types;
11    let
12      confAtom = nullOr (oneOf [ bool int float str ]) // {
13        description = "Swaynag config atom (null, bool, int, float, str)";
14      };
15    in attrsOf confAtom;
16in {
17  meta.maintainers = with maintainers; [ polykernel ];
18
19  options = {
20    wayland.windowManager.sway.swaynag = {
21      enable = mkEnableOption
22        "configuration of swaynag, a lightweight error bar for sway";
23
24      settings = mkOption {
25        type = types.attrsOf confFormat;
26        default = { };
27        description = ''
28          Configuration written to
29          {file}`$XDG_CONFIG_HOME/swaynag/config`.
30
31          See
32          {manpage}`swaynag(5)`
33          for a list of available options and an example configuration.
34          Note, configurations declared under `<config>`
35          will override the default type values of swaynag.
36        '';
37        example = literalExpression ''
38          {
39            "<config>" = {
40              edge = "bottom";
41              font = "Dina 12";
42            };
43
44            green = {
45              edge = "top";
46              background = "00AA00";
47              text = "FFFFFF";
48              button-background = "00CC00";
49              message-padding = 10;
50            };
51          }
52        '';
53      };
54    };
55  };
56
57  config = mkIf cfg.enable {
58    assertions = [
59      (hm.assertions.assertPlatform "wayland.windowManager.sway.swaynag" pkgs
60        platforms.linux)
61    ];
62
63    xdg.configFile."swaynag/config" = mkIf (cfg.settings != { }) {
64      source = iniFormat.generate "swaynag.conf" cfg.settings;
65    };
66  };
67}