~ruther/nix-tmpactivator

ref: 58dd1f391141cb0b92f9582d803e9510a13e1bbe nix-tmpactivator/modules/desktop-items.nix -rw-r--r-- 1.0 KiB
58dd1f39 — Rutherther feat: add self management (auto activation, deactivation) a year 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
{ pkgs, lib, config, ... }:

let
  mkStrOption = lib.mkOption { type = lib.types.str; };
  mkStrNullOption = lib.mkOption { type = lib.types.nullOr lib.types.str; default = null; };

  desktopItems = lib.mapAttrs (name: conf: (pkgs.makeDesktopItem {
    inherit name;
    inherit (conf) desktopName exec icon path;
  }) + "/share/applications/${name}.desktop") config.desktopItems.items;
in {
  options = {
    desktopItems = {
      enable = lib.mkEnableOption "desktop items";

      items = lib.mkOption {
        type = lib.types.attrsOf (lib.types.submodule ({ config, ... }: {
          options = {
            desktopName = mkStrOption;
            exec = mkStrOption;
            icon = mkStrNullOption;
            path = mkStrNullOption;
          };
        }));
        default = [];
      };
    };
  };

  config = lib.mkIf config.desktopItems.enable {

    home.file = lib.mapAttrs'
      (name: conf:
        lib.nameValuePair
          ".local/share/applications/${name}.desktop"
          { source = conf; }
      )
      desktopItems;
  };
}
Do not follow this link