1{
2 config,
3 lib,
4 pkgs,
5 ...
6}:
7{
8 meta = {
9 maintainers = lib.teams.freedesktop.members;
10 };
11
12 options = {
13 xdg.icons.enable = lib.mkOption {
14 type = lib.types.bool;
15 default = true;
16 description = ''
17 Whether to install files to support the
18 [XDG Icon Theme specification](https://specifications.freedesktop.org/icon-theme-spec/latest).
19 '';
20 };
21 xdg.icons.fallbackCursorThemes = lib.mkOption {
22 type = lib.types.listOf lib.types.str;
23 default = [ ];
24 description = ''
25 Names of the fallback cursor themes, in order of preference, to be used when no other icon source can be found.
26 Set to `[]` to disable the fallback entirely.
27 '';
28 };
29 };
30
31 config = lib.mkIf config.xdg.icons.enable {
32 environment.pathsToLink = [
33 "/share/icons"
34 "/share/pixmaps"
35 ];
36
37 environment.systemPackages = [
38 # Empty icon theme that contains index.theme file describing directories
39 # where toolkits should look for icons installed by apps.
40 pkgs.hicolor-icon-theme
41 ]
42 ++ lib.optionals (config.xdg.icons.fallbackCursorThemes != [ ]) [
43 (pkgs.writeTextFile {
44 name = "fallback-cursor-theme";
45 text = ''
46 [Icon Theme]
47 Inherits=${lib.concatStringsSep "," config.xdg.icons.fallbackCursorThemes}
48 '';
49 destination = "/share/icons/default/index.theme";
50 })
51 ];
52
53 # libXcursor looks for cursors in XCURSOR_PATH
54 # it mostly follows the spec for icons
55 # See: https://www.x.org/releases/current/doc/man/man3/Xcursor.3.xhtml Themes
56
57 # These are preferred so they come first in the list
58 environment.sessionVariables.XCURSOR_PATH = [
59 "$HOME/.icons"
60 "$HOME/.local/share/icons"
61 ];
62
63 environment.profileRelativeSessionVariables.XCURSOR_PATH = [
64 "/share/icons"
65 "/share/pixmaps"
66 ];
67 };
68
69}