mirror of
https://github.com/nix-community/home-manager.git
synced 2025-03-26 01:51:37 +00:00
home-cursor: use .enable pattern
This commit is contained in:
parent
32531e4572
commit
00712ac0fb
1 changed files with 99 additions and 76 deletions
|
@ -7,8 +7,19 @@ let
|
||||||
|
|
||||||
cfg = config.home.pointerCursor;
|
cfg = config.home.pointerCursor;
|
||||||
|
|
||||||
|
enable = if (lib.versionOlder config.home.stateVersion "25.05") then
|
||||||
|
# respect .enable if it is declared
|
||||||
|
if (any (x: x ? enable) options.home.pointerCursor.definitions) then
|
||||||
|
cfg.enable
|
||||||
|
else
|
||||||
|
cfg != null
|
||||||
|
else
|
||||||
|
(cfg ? enable) && cfg.enable;
|
||||||
|
|
||||||
pointerCursorModule = types.submodule {
|
pointerCursorModule = types.submodule {
|
||||||
options = {
|
options = {
|
||||||
|
enable = mkEnableOption "cursor config generation";
|
||||||
|
|
||||||
package = mkOption {
|
package = mkOption {
|
||||||
type = types.package;
|
type = types.package;
|
||||||
example = literalExpression "pkgs.vanilla-dmz";
|
example = literalExpression "pkgs.vanilla-dmz";
|
||||||
|
@ -65,8 +76,7 @@ let
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
cursorPath =
|
cursorPath = "${cfg.package}/share/icons/${escapeShellArg cfg.name}/cursors/${
|
||||||
"${cfg.package}/share/icons/${escapeShellArg cfg.name}/cursors/${
|
|
||||||
escapeShellArg cfg.x11.defaultCursor
|
escapeShellArg cfg.x11.defaultCursor
|
||||||
}";
|
}";
|
||||||
|
|
||||||
|
@ -109,25 +119,17 @@ in {
|
||||||
"x11"
|
"x11"
|
||||||
"defaultCursor"
|
"defaultCursor"
|
||||||
])
|
])
|
||||||
|
|
||||||
({ ... }: {
|
|
||||||
warnings = lib.optional (lib.any (x:
|
|
||||||
lib.getAttrFromPath
|
|
||||||
([ "xsession" "pointerCursor" ] ++ [ x ] ++ [ "isDefined" ])
|
|
||||||
options) [ "package" "name" "size" "defaultCursor" ]) ''
|
|
||||||
The option `xsession.pointerCursor` has been merged into `home.pointerCursor` and will be removed
|
|
||||||
in the future. Please change to set `home.pointerCursor` directly and enable `home.pointerCursor.x11.enable`
|
|
||||||
to generate x11 specific cursor configurations. You can refer to the documentation for more details.
|
|
||||||
'';
|
|
||||||
})
|
|
||||||
];
|
];
|
||||||
|
|
||||||
options = {
|
options = {
|
||||||
home.pointerCursor = mkOption {
|
home.pointerCursor = mkOption {
|
||||||
type = types.nullOr pointerCursorModule;
|
type = types.nullOr pointerCursorModule;
|
||||||
default = null;
|
default = if (lib.versionOlder config.home.stateVersion "25.05") then
|
||||||
|
null
|
||||||
|
else
|
||||||
|
{ };
|
||||||
description = ''
|
description = ''
|
||||||
Cursor configuration. Set to `null` to disable.
|
Cursor configuration.
|
||||||
|
|
||||||
Top-level options declared under this submodule are backend independent
|
Top-level options declared under this submodule are backend independent
|
||||||
options. Options declared under namespaces such as `x11`
|
options. Options declared under namespaces such as `x11`
|
||||||
|
@ -146,78 +148,99 @@ in {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = lib.mkIf (cfg != null) (lib.mkMerge [
|
config = mkMerge [
|
||||||
{
|
(mkIf enable (mkMerge [
|
||||||
assertions = [
|
{
|
||||||
(lib.hm.assertions.assertPlatform "home.pointerCursor" pkgs
|
assertions = [
|
||||||
lib.platforms.linux)
|
(hm.assertions.assertPlatform "home.pointerCursor" pkgs
|
||||||
];
|
lib.platforms.linux)
|
||||||
|
];
|
||||||
|
|
||||||
home.packages = [ cfg.package defaultIndexThemePackage ];
|
home.packages = [ cfg.package defaultIndexThemePackage ];
|
||||||
|
|
||||||
home.sessionVariables = {
|
home.sessionVariables = {
|
||||||
XCURSOR_SIZE = mkDefault cfg.size;
|
XCURSOR_SIZE = mkDefault cfg.size;
|
||||||
XCURSOR_THEME = mkDefault cfg.name;
|
XCURSOR_THEME = mkDefault cfg.name;
|
||||||
};
|
};
|
||||||
|
|
||||||
# Set directory to look for cursors in, needed for some applications
|
# Set directory to look for cursors in, needed for some applications
|
||||||
# that are unable to find cursors otherwise. See:
|
# that are unable to find cursors otherwise. See:
|
||||||
# https://github.com/nix-community/home-manager/issues/2812
|
# https://github.com/nix-community/home-manager/issues/2812
|
||||||
# https://wiki.archlinux.org/title/Cursor_themes#Environment_variable
|
# https://wiki.archlinux.org/title/Cursor_themes#Environment_variable
|
||||||
home.sessionSearchVariables.XCURSOR_PATH =
|
home.sessionSearchVariables.XCURSOR_PATH =
|
||||||
[ "${config.home.profileDirectory}/share/icons" ];
|
[ "${config.home.profileDirectory}/share/icons" ];
|
||||||
|
|
||||||
# Add symlink of cursor icon directory to $HOME/.icons, needed for
|
# Add cursor icon link to $XDG_DATA_HOME/icons as well for redundancy.
|
||||||
# backwards compatibility with some applications. See:
|
xdg.dataFile."icons/default/index.theme".source =
|
||||||
# https://specifications.freedesktop.org/icon-theme-spec/latest/ar01s03.html
|
"${defaultIndexThemePackage}/share/icons/default/index.theme";
|
||||||
home.file.".icons/default/index.theme".source =
|
xdg.dataFile."icons/${cfg.name}".source =
|
||||||
"${defaultIndexThemePackage}/share/icons/default/index.theme";
|
"${cfg.package}/share/icons/${cfg.name}";
|
||||||
home.file.".icons/${cfg.name}".source =
|
|
||||||
"${cfg.package}/share/icons/${cfg.name}";
|
|
||||||
|
|
||||||
# Add cursor icon link to $XDG_DATA_HOME/icons as well for redundancy.
|
# Add symlink of cursor icon directory to $HOME/.icons, needed for
|
||||||
xdg.dataFile."icons/default/index.theme".source =
|
# backwards compatibility with some applications. See:
|
||||||
"${defaultIndexThemePackage}/share/icons/default/index.theme";
|
# https://specifications.freedesktop.org/icon-theme-spec/latest/ar01s03.html
|
||||||
xdg.dataFile."icons/${cfg.name}".source =
|
home.file.".icons/default/index.theme".source =
|
||||||
"${cfg.package}/share/icons/${cfg.name}";
|
"${defaultIndexThemePackage}/share/icons/default/index.theme";
|
||||||
}
|
home.file.".icons/${cfg.name}".source =
|
||||||
|
"${cfg.package}/share/icons/${cfg.name}";
|
||||||
|
}
|
||||||
|
|
||||||
(lib.mkIf cfg.x11.enable {
|
(mkIf cfg.x11.enable {
|
||||||
xsession.profileExtra = ''
|
xsession.profileExtra = ''
|
||||||
${pkgs.xorg.xsetroot}/bin/xsetroot -xcf ${cursorPath} ${
|
${pkgs.xorg.xsetroot}/bin/xsetroot -xcf ${cursorPath} ${
|
||||||
toString cfg.size
|
toString cfg.size
|
||||||
}
|
}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
xresources.properties = {
|
xresources.properties = {
|
||||||
"Xcursor.theme" = cfg.name;
|
"Xcursor.theme" = cfg.name;
|
||||||
"Xcursor.size" = cfg.size;
|
"Xcursor.size" = cfg.size;
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
|
|
||||||
(lib.mkIf cfg.gtk.enable {
|
(mkIf cfg.gtk.enable {
|
||||||
gtk.cursorTheme = mkDefault { inherit (cfg) package name size; };
|
gtk.cursorTheme = mkDefault { inherit (cfg) package name size; };
|
||||||
})
|
})
|
||||||
|
|
||||||
(lib.mkIf cfg.hyprcursor.enable {
|
(mkIf cfg.hyprcursor.enable {
|
||||||
home.sessionVariables = {
|
home.sessionVariables = {
|
||||||
HYPRCURSOR_THEME = cfg.name;
|
HYPRCURSOR_THEME = cfg.name;
|
||||||
HYPRCURSOR_SIZE =
|
HYPRCURSOR_SIZE = if cfg.hyprcursor.size != null then
|
||||||
if cfg.hyprcursor.size != null then cfg.hyprcursor.size else cfg.size;
|
cfg.hyprcursor.size
|
||||||
};
|
else
|
||||||
})
|
cfg.size;
|
||||||
|
};
|
||||||
|
})
|
||||||
|
|
||||||
(lib.mkIf cfg.sway.enable {
|
(mkIf cfg.sway.enable {
|
||||||
wayland.windowManager.sway = {
|
wayland.windowManager.sway = {
|
||||||
config = {
|
config = {
|
||||||
seat = {
|
seat = {
|
||||||
"*" = {
|
"*" = {
|
||||||
xcursor_theme =
|
xcursor_theme =
|
||||||
"${cfg.name} ${toString config.gtk.cursorTheme.size}";
|
"${cfg.name} ${toString config.gtk.cursorTheme.size}";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
})
|
||||||
})
|
]))
|
||||||
]);
|
|
||||||
|
{
|
||||||
|
warnings = (optional (any (x:
|
||||||
|
getAttrFromPath
|
||||||
|
([ "xsession" "pointerCursor" ] ++ [ x ] ++ [ "isDefined" ])
|
||||||
|
options) [ "package" "name" "size" "defaultCursor" ]) ''
|
||||||
|
The option `xsession.pointerCursor` has been merged into `home.pointerCursor` and will be removed
|
||||||
|
in the future. Please change to set `home.pointerCursor` directly and enable `home.pointerCursor.x10.enable`
|
||||||
|
to generate x10 specific cursor configurations. You can refer to the documentation for more details.
|
||||||
|
'') ++ (optional ((lib.versionAtLeast config.home.stateVersion "25.05")
|
||||||
|
&& (cfg == null)) ''
|
||||||
|
Setting home.pointerCursor to null is deprecated.
|
||||||
|
Please update your configuration so that
|
||||||
|
|
||||||
|
home.pointerCursor.enable = false;
|
||||||
|
'');
|
||||||
|
}
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue