treewide: use mkEnableTargetWith for dynamic conditions

Ensure enable options with dynamic `autoEnable` are documented
correctly.
This commit is contained in:
Matt Sturgeon 2025-05-09 14:34:10 +01:00
parent 67b4644e70
commit 289356d031
No known key found for this signature in database
GPG key ID: 4F91844CED1A8299
6 changed files with 40 additions and 16 deletions

View file

@ -15,6 +15,14 @@ mkTarget {
|| i3.enable
|| spectrwm.enable
|| xmonad.enable;
autoEnableExpr = ''
with config.xsession.windowManager;
bspwm.enable
|| herbstluftwm.enable
|| i3.enable
|| spectrwm.enable
|| xmonad.enable
'';
configElements =
{ imageScalingMode, image }:

View file

@ -11,6 +11,10 @@ mkTarget {
autoEnable =
with config.services.xserver.windowManager;
xmonad.enable || i3.enable;
autoEnableExpr = ''
with services.xserver.windowManager;
xmonad.enable || i3.enable
'';
configElements =
{ image, imageScalingMode }:

View file

@ -44,7 +44,11 @@ let
in
{
options.stylix.targets.gnome = {
enable = config.lib.stylix.mkEnableTarget "GNOME" pkgs.stdenv.hostPlatform.isLinux;
enable = config.lib.stylix.mkEnableTargetWith {
name = "GNOME";
autoEnable = pkgs.stdenv.hostPlatform.isLinux;
autoEnableExpr = "pkgs.stdenv.hostPlatform.isLinux";
};
useWallpaper = config.lib.stylix.mkEnableWallpaper "GNOME" true;
};

View file

@ -7,9 +7,11 @@
mkTarget {
name = "hyprland";
humanName = "Hyprland";
extraOptions.hyprpaper.enable = config.lib.stylix.mkEnableTarget "Hyprpaper" (
config.stylix.image != null
);
extraOptions.hyprpaper.enable = config.lib.stylix.mkEnableTargetWith {
name = "Hyprpaper";
autoEnable = config.stylix.image != null;
autoEnableExpr = "stylix.image != null";
};
configElements = [
(
{ colors }:

View file

@ -13,9 +13,11 @@
#
# [1]: https://github.com/nix-community/stylix/issues/933
# [2]: https://github.com/nix-community/home-manager/issues/6565
enable = config.lib.stylix.mkEnableTarget "QT" (
pkgs.stdenv.hostPlatform.isLinux && osConfig != null
);
enable = config.lib.stylix.mkEnableTargetWith {
name = "QT";
autoEnable = pkgs.stdenv.hostPlatform.isLinux && osConfig != null;
autoEnableExpr = "pkgs.stdenv.hostPlatform.isLinux && osConfig != null";
};
platform = lib.mkOption {
description = ''

View file

@ -26,15 +26,19 @@ in
})
];
options.stylix.targets.swaylock = {
enable =
config.lib.stylix.mkEnableTarget "Swaylock"
# When the state version is older than 23.05, Swaylock enables itself
# automatically if `settings != {}` [1]. Therefore, Swaylock theming
# shouldn't be enabled by default for such state versions, to avoid
# inadvertently installing Swaylock when it's not desired.
#
# [1]: https://github.com/nix-community/home-manager/blob/5cfbf5cc37a3bd1da07ae84eea1b828909c4456b/modules/programs/swaylock.nix#L12-L17
(lib.versionAtLeast config.home.stateVersion "23.05");
enable = config.lib.stylix.mkEnableTargetWith {
name = "Swaylock";
# When the state version is older than 23.05, Swaylock enables itself
# automatically if `settings != {}` [1]. Therefore, Swaylock theming
# shouldn't be enabled by default for such state versions, to avoid
# inadvertently installing Swaylock when it's not desired.
#
# [1]: https://github.com/nix-community/home-manager/blob/5cfbf5cc37a3bd1da07ae84eea1b828909c4456b/modules/programs/swaylock.nix#L12-L17
autoEnable = lib.versionAtLeast config.home.stateVersion "23.05";
autoEnableExpr = ''
lib.versionAtLeast home.stateVersion "23.05"
'';
};
useWallpaper = config.lib.stylix.mkEnableWallpaper "Swaylock" true;
};