From 5d1ed786ff997aafd9021f8de5cef4b21d9e408c Mon Sep 17 00:00:00 2001 From: Flameopathic Date: Tue, 10 Jun 2025 05:02:26 -0400 Subject: [PATCH 1/2] deadnix: ignore bindings starting with _ --- flake/pre-commit.nix | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/flake/pre-commit.nix b/flake/pre-commit.nix index dda19542..ba42849c 100644 --- a/flake/pre-commit.nix +++ b/flake/pre-commit.nix @@ -11,7 +11,11 @@ check.enable = true; settings.hooks = { - deadnix.enable = true; + deadnix = { + enable = true; + settings.noUnderscore = true; + }; + editorconfig-checker.enable = true; hlint.enable = true; From 744385eedf233d53c0701e3845c826b70016a8b7 Mon Sep 17 00:00:00 2001 From: Flameopathic Date: Tue, 10 Jun 2025 05:03:07 -0400 Subject: [PATCH 2/2] mkTarget: allow _${arg} --- stylix/mk-target.nix | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/stylix/mk-target.nix b/stylix/mk-target.nix index 5fd048f0..70d3023f 100644 --- a/stylix/mk-target.nix +++ b/stylix/mk-target.nix @@ -125,6 +125,11 @@ ) ``` + Arguments prefixed with an underscore (`_`) resolve to their non-prefixed + counterparts. For example, the `_colors` argument resolves to `colors`. + Underscored arguments are considered unused and should never be accessed. + Their sole purpose is satisfying `deadnix` in complex configurations. + `generalConfig` (Attribute set or function) : This argument mirrors the `configElements` argument but intentionally lacks automatic safeguarding and should only be used for complex @@ -200,17 +205,24 @@ let fn: lib.genAttrs (functionArgNames fn) ( arg: - if arg == "cfg" then + let + trimmedArg = + let + prefix = "_"; + in + if lib.hasPrefix prefix arg then lib.removePrefix prefix arg else arg; + in + if trimmedArg == "cfg" then cfg - else if arg == "colors" then + else if trimmedArg == "colors" then config.lib.stylix.colors else - config.stylix.${arg} + config.stylix.${trimmedArg} or (throw "stylix: mkTarget expected one of `cfg`, `colors`, ${ lib.concatMapStringsSep ", " (name: "`${name}`") ( builtins.attrNames config.stylix ) - }, but got: ${arg}") + }, but got: ${trimmedArg}") ); # Call the configuration function with its required Stylix arguments.