summaryrefslogtreecommitdiffstats
path: root/nixos/modules/config/xdg/icons.nix
blob: 41eee42767f4cde5ca26bf3c3178b159861c2ddb (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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
{
  config,
  lib,
  pkgs,
  ...
}:
{
  meta = {
    teams = [ lib.teams.freedesktop ];
  };

  options = {
    xdg.icons.enable = lib.mkOption {
      type = lib.types.bool;
      default = true;
      description = ''
        Whether to install files to support the
        [XDG Icon Theme specification](https://specifications.freedesktop.org/icon-theme-spec/latest).
      '';
    };
    xdg.icons.fallbackCursorThemes = lib.mkOption {
      type = lib.types.listOf lib.types.str;
      default = [ ];
      description = ''
        Names of the fallback cursor themes, in order of preference, to be used when no other icon source can be found.
        Set to `[]` to disable the fallback entirely.
      '';
    };
  };

  config = lib.mkIf config.xdg.icons.enable {
    environment.pathsToLink = [
      "/share/icons"
      "/share/pixmaps"
    ];

    environment.systemPackages = [
      # Empty icon theme that contains index.theme file describing directories
      # where toolkits should look for icons installed by apps.
      pkgs.hicolor-icon-theme
    ]
    ++ lib.optionals (config.xdg.icons.fallbackCursorThemes != [ ]) [
      (pkgs.writeTextFile {
        name = "fallback-cursor-theme";
        text = ''
          [Icon Theme]
          Inherits=${lib.concatStringsSep "," config.xdg.icons.fallbackCursorThemes}
        '';
        destination = "/share/icons/default/index.theme";
      })
    ];

    # libXcursor looks for cursors in XCURSOR_PATH
    # it mostly follows the spec for icons
    # See: https://www.x.org/releases/current/doc/man/man3/Xcursor.3.xhtml Themes

    # These are preferred so they come first in the list
    environment.sessionVariables.XCURSOR_PATH = [
      "$HOME/.icons"
      "$HOME/.local/share/icons"
    ];

    environment.profileRelativeSessionVariables.XCURSOR_PATH = [
      "/share/icons"
      "/share/pixmaps"
    ];
  };

}