From 1832ffa9a27037388277591612af7437d1bd2bad Mon Sep 17 00:00:00 2001 From: Flameopathic <64027365+Flameopathic@users.noreply.github.com> Date: Wed, 2 Apr 2025 10:06:11 -0400 Subject: [PATCH] stylix: prevent partially declared cursor (#1080) Closes: https://github.com/danth/stylix/issues/1064 Link: https://github.com/danth/stylix/pull/1080 Reviewed-by: awwpotato <153149335+awwpotato@users.noreply.github.com> Reviewed-by: NAHO <90870942+trueNAHO@users.noreply.github.com> --- stylix/cursor.nix | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/stylix/cursor.nix b/stylix/cursor.nix index 2e6b371d..a892e449 100644 --- a/stylix/cursor.nix +++ b/stylix/cursor.nix @@ -1,26 +1,47 @@ -{ lib, ... }: +{ lib, config, ... }: { options.stylix.cursor = lib.mkOption { - description = "Attributes defining the systemwide cursor."; + description = '' + Attributes defining the systemwide cursor. Set either all or none of + these attributes. + ''; type = lib.types.nullOr ( lib.types.submodule { options = { name = lib.mkOption { description = "The cursor name within the package."; - type = lib.types.str; + type = lib.types.nullOr lib.types.str; + default = null; }; package = lib.mkOption { description = "Package providing the cursor theme."; - type = lib.types.package; + type = lib.types.nullOr lib.types.package; + default = null; }; size = lib.mkOption { description = "The cursor size."; - type = lib.types.int; + type = lib.types.nullOr lib.types.int; + default = null; }; }; } ); default = null; }; + config.assertions = + let + inherit (config.stylix) cursor; + in + [ + { + assertion = + cursor == null + || cursor.name != null && cursor.package != null && cursor.size != null; + message = '' + stylix: `stylix.cursor` is only partially defined. Set either none or + all of the `stylix.cursor` options. + ''; + } + ]; }