~ruther/nixos-config

ref: 4429e050649adc6733552021cbcd1f88f591d97d nixos-config/home/modules/profiles/desktop/dwl/mako.nix -rw-r--r-- 2.4 KiB
4429e050 — Frantisek Bohacek feat: add mako program 8 months ago
                                                                                
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
80
81
82
83
84
{ config, lib, pkgs, ... }:

let
  cfg = config.rutherther.programs.mako;

  inherit (lib) mkOption mkEnableOption mkPackageOption;
  inherit (lib.types) str package number path attrsOf listOf oneOf submodule;

  configOptionType = oneOf [ str number ];
  configOptionsType = attrsOf configOptionType;
  mapConfigOptions = options: lib.mapAttrsToList (name: value: "${name}=${builtins.toString value}") options;
  sectionsType = submodule ({ config, ... }: {
    options = {
      conditions = mkOption {
        type = configOptionsType;
        description = "The conditions for current section.";
        example = {
          urgency = "critical";
        };
      };
      config = mkOption {
        type = configOptionsType;
        description = "Options to configure for the specified condition.";
        example = {
          border-color = "#FFFFFFFF";
        };
      };
      configText = mkOption {
        type = str;
        readOnly = true;
      };
    };

    config = {
      configText = ''[${lib.concatStringsSep " " (mapConfigOptions config.conditions)}]
${lib.concatStringsSep "\n" (mapConfigOptions config.config)}'';
    };
  });

  sectionsConfigs = lib.lists.map (section: section.configText) cfg.config.sections;
in {
  options.rutherther.programs.mako = {
    enable = mkEnableOption "Program - simple wayland notification daemon";

    package = mkPackageOption pkgs "mako" {};

    config.default = mkOption {
      type = configOptionsType;
      description = ''
        Text for the configuration file.
      '';
    };

    config.sections = mkOption {
      type = listOf sectionsType;
      description = "Sections to append to the config file. These apply only if conditions for those are satisfied.";
    };

    configFile = mkOption {
      type = package;
      readOnly = true;
      description = "Resulting file with the configuration text.";
    };

    configText = mkOption {
      type = str;
      readOnly = true;
      description = ''
        Resulting text of the configuration file.
      '';
    };

    dbusFile = mkOption {
      type = path;
      description = "D-Bus service file";
    };
  };

  config.rutherther.programs.mako = {
    configText = lib.concatStringsSep "\n" ((mapConfigOptions cfg.config.default) ++ sectionsConfigs) + "\n";
    configFile = pkgs.writeText "mako-config" cfg.configText;
    dbusFile = "${cfg.package}/share/dbus/fr.emersion.mako.service";
  };
}
Do not follow this link