aboutsummaryrefslogtreecommitdiff
path: root/modules/redux/nickle.nix
blob: b08a6ec6e135f0a093cbe3394cbc384bbcac6b86 (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
{ config, pkgs, lib, options, ... }:
with builtins // lib;
let
  cfg = config.nickle;
in {
  options.nickle = {
    enable = mkEnableOption "NickleMenu";

    path = mkOption {
      type = types.str;
      default = ".adds/nm";
      description = "Relative path to NickleMenu within src";
    };

    file = mkOption {
      type = options.file.type;
      default = {};
      description = "Files relative to ${cfg.path}";
    };

    menuItems = mkOption {
      type = with types; attrsOf (listOf str);
      default = {};
    };
  };

  config = mkIf cfg.enable {
    nickle = {
      file = mapAttrs (_: v: {
        text = concatStringsSep " : " ([ "menu_item" ] ++ v)
      }) cfg.menuItems
    };

    file = mapAttrs' (n: v: {
      name = "nm-${n}";
      value = v // {
        target = "${cfg.path}/${v.target}";
      };
    }) cfg.file
  };
}