aboutsummaryrefslogtreecommitdiffstats
path: root/modules/lib/default.nix
blob: fd54fa2a3249379874fdf47480b8d6cfc78bbc2a (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
# Internal aggregation for script modules registered via mkScriptModule
{
  config,
  lib,
  ...
}:
{
  options.scriptPaths = lib.mkOption {
    type = lib.types.listOf (lib.types.listOf lib.types.str);
    default = [ ];
    internal = true;
    description = "Attr paths of script modules registered via mkScriptModule.";
  };

  config = {
    home.packages = lib.filter (p: p != null) (
      map (path: (lib.getAttrFromPath path config).package) config.scriptPaths
    );

    xdg.desktopEntries = lib.listToAttrs (
      map
        (
          path:
          let
            name = lib.last path;
            sc = lib.getAttrFromPath path config;
          in
          lib.nameValuePair name {
            name = sc.desktop.displayName;
            exec = "${lib.getExe config.terminal.kitty.package} --class ${name} -e ${lib.getExe sc.package}";
            icon = sc.desktop.icon;
            categories = [ "Utility" ];
            terminal = false;
            type = "Application";
          }
        )
        (
          lib.filter (
            path:
            let
              sc = lib.getAttrFromPath path config;
            in
            sc.enable && sc.desktop.enable
          ) config.scriptPaths
        )
    );
  };
}