stylix icon indicating copy to clipboard operation
stylix copied to clipboard

stylix/mk-target: polish, simplify, and extend interface

Open trueNAHO opened this issue 5 months ago • 5 comments

Polish the mkTarget implementation and interface, simplify its interface
by optionally inferring its 'humanName' and 'name' arguments, and
generate targets.${target}.${argument}.enable and
targets.${target}.${argument}.override options for disabling and
configuring safeguarded arguments on a target level.
commit c6d8acdd8290ff8c588a71e776f4bf2d6571a6ad
Author: NAHO <[email protected]>
Date:   2025-11-21 19:05:21 +0100

    modules: flatten single-attribute set declarations

 modules/cava/hm.nix       |  4 +---
 modules/hyprlock/hm.nix   |  4 +---
 modules/lightdm/nixos.nix |  4 +---
 modules/yazi/hm.nix       | 10 ++++------
 4 files changed, 7 insertions(+), 15 deletions(-)

commit 305f75a8311a746cd332c0b7291d1c9c46fcaddd
Author: NAHO <[email protected]>
Date:   2025-07-19 11:28:32 +0200

    stylix/mk-target: sort optional arguments

 stylix/mk-target.nix | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)

commit 5a256109b83bcfc177c0da3249d5f16671b2f147
Author: NAHO <[email protected]>
Date:   2025-07-19 11:28:33 +0200

    stylix/mk-target: document imports argument

    Fixes: 093087e969e2 ("stylix: add imports to mkTarget (#1363)")

 stylix/mk-target.nix | 3 +++
 1 file changed, 3 insertions(+)

commit 81c5ea40b0caab5e85c875863aefa00b0a21a038
Author: NAHO <[email protected]>
Date:   2025-11-21 20:12:08 +0100

    stylix/mk-target: rename mkConfig function to callModule

    Rename the mkConfig function to callModule to generalize the name beyond
    the specific config and options module arguments.

    Fixes: dea0337e0bff ("stylix: restrict access to config while using mkTarget (#1368)")

 stylix/mk-target.nix | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

commit 71489085e98fee32de1444957c1afa25f65c5250
Author: NAHO <[email protected]>
Date:   2025-07-19 11:28:34 +0200

    stylix/mk-target: polish implementation and improve error reporting

    Polish the mkTarget implementation to improve error reporting and
    simplify future enhancements.

    Configuration elements can now recursively resolve to paths.

 stylix/mk-target.nix | 114 +++++++++++++++++++++++++++------------------------
 1 file changed, 60 insertions(+), 54 deletions(-)

commit f5278e9eff2f7bc1123c8f200e9a569d0c358a0c
Author: NAHO <[email protected]>
Date:   2025-07-19 11:28:34 +0200

    stylix/mk-target: rename generalConfig argument to unconditionalConfig

    Rename the generalConfig argument to unconditionalConfig to better imply
    the intentional lack of safeguarding.

 stylix/mk-target.nix | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

commit 2b744cb4cc89f051b1f6a84341b5e0ff6eab29a8
Author: NAHO <[email protected]>
Date:   2025-07-19 11:28:35 +0200

    treewide: rename mkTarget's configElements and extraOptions options

    Rename mkTarget's 'configElements' argument to 'config' and
    'extraOptions' to 'options' to provide a more transparent interface with
    the underlying Nixpkgs module system.

 doc/src/modules.md                |  2 +-
 modules/alacritty/hm.nix          |  2 +-
 modules/anki/hm.nix               |  2 +-
 modules/ashell/hm.nix             |  2 +-
 modules/avizo/hm.nix              |  2 +-
 modules/bat/hm.nix                |  2 +-
 modules/bemenu/hm.nix             |  4 ++--
 modules/blender/hm.nix            |  4 ++--
 modules/bspwm/hm.nix              |  2 +-
 modules/btop/hm.nix               |  2 +-
 modules/cava/hm.nix               |  4 ++--
 modules/cavalier/hm.nix           |  2 +-
 modules/chromium/nixos.nix        |  2 +-
 modules/console/droid.nix         |  2 +-
 modules/console/nixos.nix         |  2 +-
 modules/discord/nixcord.nix       |  4 ++--
 modules/discord/vencord.nix       |  4 ++--
 modules/discord/vesktop.nix       |  4 ++--
 modules/dunst/hm.nix              |  2 +-
 modules/emacs/hm.nix              |  2 +-
 modules/eog/hm.nix                |  2 +-
 modules/fcitx5/hm.nix             |  2 +-
 modules/feh/hm.nix                |  2 +-
 modules/feh/nixos.nix             |  2 +-
 modules/firefox/each-config.nix   |  4 ++--
 modules/fish/hm.nix               |  2 +-
 modules/fish/nixos.nix            |  2 +-
 modules/fnott/hm.nix              |  2 +-
 modules/foliate/hm.nix            |  2 +-
 modules/font-packages/darwin.nix  |  2 +-
 modules/font-packages/hm.nix      |  2 +-
 modules/font-packages/nixos.nix   |  2 +-
 modules/fontconfig/fontconfig.nix |  2 +-
 modules/foot/hm.nix               |  2 +-
 modules/forge/hm.nix              |  2 +-
 modules/fuzzel/hm.nix             |  2 +-
 modules/fzf/hm.nix                |  2 +-
 modules/gdu/hm.nix                |  2 +-
 modules/gedit/hm.nix              |  2 +-
 modules/ghostty/hm.nix            |  2 +-
 modules/gitui/hm.nix              |  2 +-
 modules/glance/hm.nix             |  2 +-
 modules/glance/nixos.nix          |  2 +-
 modules/gnome-text-editor/hm.nix  |  2 +-
 modules/gnome/hm.nix              |  4 ++--
 modules/gtk/hm.nix                |  4 ++--
 modules/gtk/nixos.nix             |  2 +-
 modules/gtksourceview/hm.nix      |  2 +-
 modules/halloy/hm.nix             |  2 +-
 modules/helix/hm.nix              |  4 ++--
 modules/hyprland/hm.nix           |  4 ++--
 modules/hyprlock/hm.nix           |  4 ++--
 modules/hyprpanel/hm.nix          |  2 +-
 modules/hyprpaper/hm.nix          |  2 +-
 modules/i3/hm.nix                 |  4 ++--
 modules/i3bar-river/hm.nix        |  2 +-
 modules/jankyborders/darwin.nix   |  2 +-
 modules/k9s/hm.nix                |  2 +-
 modules/kitty/hm.nix              |  4 ++--
 modules/kmscon/nixos.nix          |  2 +-
 modules/kubecolor/hm.nix          |  2 +-
 modules/lazygit/hm.nix            |  2 +-
 modules/lightdm/nixos.nix         |  4 ++--
 modules/limine/nixos.nix          |  4 ++--
 modules/mako/hm.nix               |  2 +-
 modules/mangohud/hm.nix           |  2 +-
 modules/micro/hm.nix              |  2 +-
 modules/mpv/hm.nix                |  2 +-
 modules/ncspot/hm.nix             |  4 ++--
 modules/neovim/neovide.nix        |  2 +-
 modules/neovim/neovim.nix         |  4 ++--
 modules/neovim/nixvim.nix         |  4 ++--
 modules/neovim/nvf.nix            |  4 ++--
 modules/neovim/vim.nix            |  2 +-
 modules/nushell/hm.nix            |  2 +-
 modules/obsidian/hm.nix           |  4 ++--
 modules/opencode/hm.nix           |  2 +-
 modules/plymouth/nixos.nix        |  4 ++--
 modules/qutebrowser/hm.nix        |  2 +-
 modules/regreet/nixos.nix         |  4 ++--
 modules/rio/hm.nix                |  2 +-
 modules/rofi/hm.nix               |  2 +-
 modules/spicetify/spicetify.nix   |  2 +-
 modules/spotify-player/hm.nix     |  2 +-
 modules/starship/hm.nix           |  2 +-
 modules/swaylock/hm.nix           |  4 ++--
 modules/swaync/hm.nix             |  2 +-
 modules/sxiv/hm.nix               |  2 +-
 modules/tmux/hm.nix               |  2 +-
 modules/tofi/hm.nix               |  2 +-
 modules/vicinae/hm.nix            |  2 +-
 modules/vscode/hm.nix             |  4 ++--
 modules/waybar/hm.nix             |  4 ++--
 modules/wayfire/hm.nix            |  4 ++--
 modules/wayprompt/hm.nix          |  2 +-
 modules/wezterm/hm.nix            |  4 ++--
 modules/wob/hm.nix                |  2 +-
 modules/wofi/hm.nix               |  2 +-
 modules/wpaperd/hm.nix            |  2 +-
 modules/xfce/hm.nix               |  2 +-
 modules/xresources/hm.nix         |  2 +-
 modules/yazi/hm.nix               |  4 ++--
 modules/zathura/hm.nix            |  2 +-
 modules/zed/hm.nix                |  2 +-
 modules/zellij/hm.nix             |  2 +-
 modules/zen-browser/hm.nix        |  4 ++--
 stylix/mk-target.nix              | 30 ++++++++++++++++--------------
 107 files changed, 152 insertions(+), 150 deletions(-)

commit a378d06399368a2f7d95bc836a47e47eb31a297f
Author: NAHO <[email protected]>
Date:   2025-07-19 11:28:36 +0200

    treewide: optionalize mkTarget's humanName and name arguments

    Optionalize mkTarget's 'humanName' and 'name' arguments by inferring
    'humanName' from the 'name' attribute in the /modules/<MODULE>/meta.nix
    file, and 'name' from the /modules/<NAME>/ directory name.

    Inferring the 'humanName' and 'name' arguments ensures consistency and
    reduces boilerplate.

    The 'humanName' and 'name' arguments are optionalized instead of removed
    because complex modules generating target derivations need to
    distinguish between them.

    Closes: https://github.com/nix-community/stylix/issues/1661

 doc/src/modules.md                  |  3 ---
 modules/alacritty/hm.nix            |  2 --
 modules/anki/hm.nix                 |  3 ---
 modules/ashell/hm.nix               |  3 ---
 modules/avizo/hm.nix                |  3 ---
 modules/bat/hm.nix                  |  3 ---
 modules/bemenu/hm.nix               |  3 ---
 modules/blender/hm.nix              |  3 ---
 modules/bspwm/hm.nix                |  3 ---
 modules/btop/hm.nix                 |  3 ---
 modules/cava/hm.nix                 |  3 ---
 modules/cavalier/hm.nix             |  3 ---
 modules/chromium/nixos.nix          |  3 ---
 modules/console/droid.nix           |  3 ---
 modules/console/nixos.nix           |  3 ---
 modules/dunst/hm.nix                |  3 ---
 modules/emacs/hm.nix                |  3 ---
 modules/eog/hm.nix                  |  3 ---
 modules/fcitx5/hm.nix               |  3 ---
 modules/feh/hm.nix                  |  2 --
 modules/feh/nixos.nix               |  2 --
 modules/firefox/each-config.nix     |  2 +-
 modules/fish/hm.nix                 |  3 ---
 modules/fish/nixos.nix              |  3 ---
 modules/fnott/hm.nix                |  3 ---
 modules/foliate/hm.nix              |  3 ---
 modules/font-packages/darwin.nix    |  3 ---
 modules/font-packages/hm.nix        |  3 ---
 modules/font-packages/nixos.nix     |  3 ---
 modules/fontconfig/fontconfig.nix   |  3 ---
 modules/foot/hm.nix                 |  3 ---
 modules/forge/hm.nix                |  3 ---
 modules/fuzzel/hm.nix               |  3 ---
 modules/fzf/hm.nix                  |  3 ---
 modules/gdu/hm.nix                  |  3 ---
 modules/gedit/hm.nix                |  3 ---
 modules/ghostty/hm.nix              |  3 ---
 modules/gitui/hm.nix                |  3 ---
 modules/glance/hm.nix               |  3 ---
 modules/glance/nixos.nix            |  3 ---
 modules/gnome-text-editor/hm.nix    |  3 ---
 modules/gnome-text-editor/nixos.nix |  6 +-----
 modules/gnome/hm.nix                |  3 ---
 modules/gtk/hm.nix                  |  3 ---
 modules/gtk/nixos.nix               |  3 ---
 modules/gtksourceview/hm.nix        |  3 ---
 modules/gtksourceview/nixos.nix     |  8 ++------
 modules/halloy/hm.nix               |  3 ---
 modules/helix/hm.nix                |  3 ---
 modules/hyprland/hm.nix             |  2 --
 modules/hyprlock/hm.nix             |  3 ---
 modules/hyprpanel/hm.nix            |  3 ---
 modules/hyprpaper/hm.nix            |  3 ---
 modules/i3/hm.nix                   |  3 ---
 modules/i3bar-river/hm.nix          |  3 ---
 modules/jankyborders/darwin.nix     |  3 ---
 modules/k9s/hm.nix                  |  3 ---
 modules/kitty/hm.nix                |  3 ---
 modules/kmscon/nixos.nix            |  3 ---
 modules/kubecolor/hm.nix            |  3 ---
 modules/lazygit/hm.nix              |  3 ---
 modules/lightdm/nixos.nix           |  3 ---
 modules/limine/nixos.nix            |  3 ---
 modules/mako/hm.nix                 |  3 ---
 modules/mangohud/hm.nix             |  3 ---
 modules/micro/hm.nix                |  3 ---
 modules/mpv/hm.nix                  |  2 --
 modules/ncspot/hm.nix               |  3 ---
 modules/nushell/hm.nix              |  3 ---
 modules/obsidian/hm.nix             |  3 ---
 modules/opencode/hm.nix             |  3 ---
 modules/plymouth/nixos.nix          |  3 ---
 modules/qutebrowser/hm.nix          |  3 ---
 modules/regreet/nixos.nix           |  3 ---
 modules/rio/hm.nix                  |  3 ---
 modules/rofi/hm.nix                 |  3 ---
 modules/spicetify/spicetify.nix     |  3 ---
 modules/spotify-player/hm.nix       |  3 ---
 modules/starship/hm.nix             |  3 ---
 modules/swaylock/hm.nix             |  3 ---
 modules/swaync/hm.nix               |  3 ---
 modules/sxiv/hm.nix                 |  3 ---
 modules/tmux/hm.nix                 |  3 ---
 modules/tofi/hm.nix                 |  3 ---
 modules/vicinae/hm.nix              |  3 ---
 modules/vscode/hm.nix               |  3 ---
 modules/waybar/hm.nix               |  3 ---
 modules/wayfire/hm.nix              |  3 ---
 modules/wayprompt/hm.nix            |  3 ---
 modules/wezterm/hm.nix              |  2 --
 modules/wob/hm.nix                  |  3 ---
 modules/wofi/hm.nix                 |  3 ---
 modules/wpaperd/hm.nix              |  3 ---
 modules/xfce/hm.nix                 |  2 --
 modules/xresources/hm.nix           |  3 ---
 modules/yazi/hm.nix                 |  3 ---
 modules/zathura/hm.nix              |  3 ---
 modules/zed/hm.nix                  |  3 ---
 modules/zellij/hm.nix               |  3 ---
 modules/zen-browser/hm.nix          |  3 ---
 stylix/autoload.nix                 | 10 ++++++++--
 stylix/darwin/default.nix           |  3 ++-
 stylix/droid/default.nix            |  4 ++--
 stylix/hm/default.nix               |  3 ++-
 stylix/mk-target.nix                | 33 ++++++++++++++++-----------------
 stylix/nixos/default.nix            |  3 ++-
 stylix/overlays.nix                 |  2 +-
 107 files changed, 37 insertions(+), 321 deletions(-)

commit 7b884405fca747596c8b38a4d655ae1ed9439fc3
Author: NAHO <[email protected]>
Date:   2025-07-19 11:28:37 +0200

    stylix/mk-target: generate options for configuring safeguarded arguments

    Generate targets.${target}.${argument}.enable and
    targets.${target}.${argument}.override options for disabling and
    configuring safeguarded arguments on a target level.

 stylix/mk-target.nix | 141 ++++++++++++++++++++++++++++++++++++++-------------
 1 file changed, 105 insertions(+), 36 deletions(-)

commit 1bc50a20c54cf046267dc82acbe9beea99284eab
Author: NAHO <[email protected]>
Date:   2025-07-19 18:40:26 +0200

    stylix/mk-target: normalize options argument identically to config

    Normalize the options argument identically to config to provide a
    coherent and extensible options interface.

 stylix/mk-target.nix | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

Changelog

v10: https://github.com/nix-community/stylix/commit/1bc50a20c54cf046267dc82acbe9beea99284eab

  • Rebase on top of commit 89f99bfeb8b6 ("vicinae: init (#1994)").

v9: https://github.com/nix-community/stylix/commit/0bfa74694cb64a658d2f91067e9ab1b4901accec

  • Rebase on top of commit 2424a3923d57 ("nixvim: remove unused config module argument (#2010)").
  • stylix/mk-target: rename mkConfig function to callModule
    • Add this commit, as discussed in https://github.com/nix-community/stylix/pull/1721#discussion_r2287074418.
  • treewide: rename mkTarget's configElements and extraOptions options
    • Extract stylistic changes into the new commit modules: flatten single-attribute set declarations.
  • stylix/mk-target: generate options for configuring safeguarded arguments
    • Fix typo, as suggested in https://github.com/nix-community/stylix/pull/1721#discussion_r2379598191.

v8: https://github.com/nix-community/stylix/commit/aa029681cc9b6fcf21c0e7c638df6216e2cf479f

  • Rebase on top of commmit 665a4ede4dbc ("anki/meta: fix name capitalization (#1820)").
  • stylix/mk-target: generate options for configuring safeguarded arguments
    • Add config.stylix.targets.${name}.${argument}.override type checking, as suggested in https://github.com/nix-community/stylix/pull/1721#discussion_r2243421308.

v7: https://github.com/nix-community/stylix/commit/4628b14c8b5f2717d2742da1c9d10c25e009867e

  • Rebase on top of commit b4e1daad3bcd ("ci: request subsystem maintainers review (#1053)").
  • stylix/mk-target: generate options for configuring safeguarded arguments
    • Rename targets.${target}.${argument}.settings to targets.${target}.${argument}.override, as suggested in https://github.com/nix-community/stylix/pull/1721#discussion_r2234097165.
    • Remove Settings merged with ${config}. documentation sentence, as suggested in https://github.com/nix-community/stylix/pull/1721#discussion_r2234097886.

v6: https://github.com/nix-community/stylix/commit/c9a0103aaf8192f596a14923e8c26dbfc576e1aa

  • Rebase on top of commit 24499b004988 ("stylix: conditionally load external modules in testbeds (#1698)").

v5: https://github.com/nix-community/stylix/commit/c0e8cde37373e97b736382102a3f2ff2bcb643fc

  • stylix/mk-target: generate options for configuring safeguarded arguments
    • Declare Stylix options before user imports and options.

v4: https://github.com/nix-community/stylix/commit/90ca0a94192ab7a9fe99e24afbead2b73853ca09

  • stylix/mk-target: generate options for configuring safeguarded arguments

    • Generate targets.${target}.${argument}.settings options for mkTarget options, resolving the regression introduced in v3.
    • Check global options first in areArgumentsEnabled, following the existing lib.mkIf convention.
    • Correctly rename targets.${target}.enable and targets.${target}.settings to targets.${target}.${argument}.enable targets.${target}.${argument}.settings in the commit message.
  • stylix/mk-target: normalize options argument identically to config

    • Add commit.

v3: https://github.com/nix-community/stylix/commit/eeac2055c1131caeca9634ad998781e9b6c90ae7

  • stylix/mk-target: generate options for disabling safeguarded arguments
    • Extend functionality to generate the targets.${target}.enable and targets.${target}.settings options instead of only the targets.${target} option.

    • Rename commit to stylix/mk-target: generate options for configuring safeguarded arguments.

    • Tested with nix run .#testbed:kitty:dark after applying the following debug patch:

      diff --git a/modules/kitty/testbeds/kitty.nix b/modules/kitty/testbeds/kitty.nix
      index 7f8f08f..508fd4b 100644
      --- a/modules/kitty/testbeds/kitty.nix
      +++ b/modules/kitty/testbeds/kitty.nix
      @@ -10,6 +10,12 @@ in
         };
      
         home-manager.sharedModules = lib.singleton {
      +    stylix.targets.kitty = {
      +      colors.enable = false;
      +      fonts.settings.sizes.terminal = 42;
      +      opacity.settings.terminal = 0.86;
      +    };
      +
           programs.kitty = {
             enable = true;
             inherit package;
      

v2: https://github.com/nix-community/stylix/pull/1721/commits/dd5389a79f7980c9601f204bde75b99711d6c10d

  • stylix/mk-target: generate options for disabling safeguarded arguments
    • Resolve stylix.targets.${target}.cfg exclusion regression introduced in v1.
    • Refactor lib.mkEnableOption description.

v1: https://github.com/nix-community/stylix/pull/1721/commits/b311b3522b72600b659e53cf3b960f6ad35d70e2

  • stylix/mk-target: sort arguments

    • Sort mandatory arguments in their intended declaration order.
    • Rename commit to stylix/mk-target: sort optional arguments.
  • stylix/mk-target: polish implementation and improve error reporting

    • Consistently polish if-then-else spacing.
  • stylix/mk-target: generate options for disabling safeguarded arguments

    • Exclude stylix.targets.${target}.cfg options.
    • Resolve the lib.mkEnableOption TODO marker by generating a different message for colors arguments.

v0: https://github.com/nix-community/stylix/pull/1721/commits/176d42104bfb0c0ce950630a38069f3e10852f55


[!NOTE]

It is strongly encouraged to review and discuss commits individually instead of the total diff.

[!IMPORTANT]

This patchset should be git rebase master before being merged to avoid uncaught internal breaking changes.

CC: @Flameopathic @MattSturgeon @awwpotato @danth


Submission Checklist

Notify Maintainers

trueNAHO avatar Jul 18 '25 22:07 trueNAHO

I disagree with renaming configElements and extraOptions because a more transparent interface with the module system hides the subtle and important differences in our interface.

The differences are major and crucial. Unknowingly treating config like unconditionalConfig would bypass mkTarget's safeguarding and the new option generation mechanism, which is a mistake that should not pass code review. The contribution documentation should clearly explain the extent and benefits of our custom module system to encourage everyone to embrace mkTarget's functionality.

trueNAHO avatar Jul 19 '25 17:07 trueNAHO

personally I like unconditionalConfig, it's a lot clearer than generalConfig. I also aesthetically like configElements to config rename but not sure if it provides much functional benefit.


It is strongly encouraged to review and discuss commits individually instead of the total diff.

personally I would prefer moving the documentation and renaming changes into separate pr(s) and have this pr be focused on functionality to reduce the number of diffs to review.

0xda157 avatar Jul 19 '25 17:07 0xda157

personally I like unconditionalConfig, it's a lot clearer than generalConfig.

Agreed

I also aesthetically like configElements to config rename but not sure if it provides much functional benefit.

I'm cautious of using overloaded names like config. That already has its own meaning(s) in the module system, so using it for your custom attribute could cause confusion.

personally I would prefer moving the documentation and renaming changes into separate pr(s) and have this pr be focused on functionality to reduce the number of diffs to review.

I agree, all PRs should strive to be as small and reviewable as possible; if sections of a PR can be extracted out into separate PRs to merge earlier or later, then that is often a good idea.

MattSturgeon avatar Jul 20 '25 02:07 MattSturgeon

I also aesthetically like configElements to config rename but not sure if it provides much functional benefit.

I'm cautious of using overloaded names like config. That already has its own meaning(s) in the module system, so using it for your custom attribute could cause confusion.

If a more transparent interface with the underlying Nixpkgs module system does not cause confusion, the transparent interface would be an improvement. I suggest optimistically applying [PATCH 5/8] treewide: rename mkTarget's configElements and extraOptions options for now, since we can always revert it if contributors frequently get confused. The contribution documentation should be extended in a follow-up PR:

The contribution documentation should clearly explain the extent and benefits of our custom module system to encourage everyone to embrace mkTarget's functionality.

personally I would prefer moving the documentation and renaming changes into separate pr(s) and have this pr be focused on functionality to reduce the number of diffs to review.

I agree, all PRs should strive to be as small and reviewable as possible; if sections of a PR can be extracted out into separate PRs to merge earlier or later, then that is often a good idea.

Initially, I submitted [PATCH 3/8] stylix/mk-target: polish implementation and improve error reporting as https://github.com/nix-community/stylix/pull/1709. Afterwards, I continued working on top of this patch, resulting in this already neatly organized patchset:

Group Patches
1 - [PATCH 1/8] stylix/mk-target: sort optional arguments
- [PATCH 2/8] stylix/mk-target: document imports argument
2 - [PATCH 3/8] stylix/mk-target: polish implementation and improve error reporting
3 - [PATCH 4/8] stylix/mk-target: rename generalConfig argument to unconditionalConfig
- [PATCH 5/8] treewide: rename mkTarget's configElements and extraOptions options
4 - [PATCH 6/8] treewide: optionalize mkTarget's humanName and name arguments
5 - [PATCH 7/8] stylix/mk-target: generate options for configuring safeguarded arguments
6 - [PATCH 8/8] stylix/mk-target: normalize options argument identically to config

I superseded https://github.com/nix-community/stylix/pull/1709 with this patchset because most patches depend on previous patches. Submitting this patchset as a sequence of PRs would synchronize discussions instead of asynchronously discussing the whole patchset. Unless further insisted, I would prefer this patchset to be reviewed as a whole, especially since I believe it is ready for merge since the added core functionality seems to be working (see the changelog notes from v3).

To review the patchset, consider taking inspiration from https://github.com/nix-community/stylix/pull/1212#pullrequestreview-2944046946, which itself was inspired by the Linux Kernel review process. Feel free to clone my branch and use all your local tooling to review. Alternatively, the following GitHub endpoints should cover most use cases:

  • https://github.com/nix-community/stylix/pull/1721.patch
  • https://github.com/nix-community/stylix/pull/1721.diff

To get a high-level overview of the generated module options from [PATCH 7/8] stylix/mk-target: generate options for configuring safeguarded arguments, consider running:

nix run github:trueNAHO/stylix/stylix-mk-target-polish-simplify-and-extend-interface#doc

trueNAHO avatar Jul 20 '25 11:07 trueNAHO

my config builds when overriding stylix with this branch

FYI and as a reminder, the changelog of v3 includes an in-tree patch for testing the target level overriding:

  • Tested with nix run .#testbed:kitty:dark after applying the following debug patch:

    diff --git a/modules/kitty/testbeds/kitty.nix b/modules/kitty/testbeds/kitty.nix
    index 7f8f08f..508fd4b 100644
    --- a/modules/kitty/testbeds/kitty.nix
    +++ b/modules/kitty/testbeds/kitty.nix
    @@ -10,6 +10,12 @@ in
       };
    
       home-manager.sharedModules = lib.singleton {
    +    stylix.targets.kitty = {
    +      colors.enable = false;
    +      fonts.settings.sizes.terminal = 42;
    +      opacity.settings.terminal = 0.86;
    +    };
    +
         programs.kitty = {
           enable = true;
           inherit package;
    

The generated options can also conveniently be inspected with:

To get a high-level overview of the generated module options from [PATCH 7/8] stylix/mk-target: generate options for configuring safeguarded arguments, consider running:

nix run github:trueNAHO/stylix/stylix-mk-target-polish-simplify-and-extend-interface#doc

As mentioned in the PR description, this PR should be up-to-date with the master branch:

[!IMPORTANT]

This patchset should be git rebase master before being merged to avoid uncaught internal breaking changes.

Upon merging this PR, new PRs should be rebased on top of this PR to avoid unexpected evaluation errors.

trueNAHO avatar Nov 21 '25 20:11 trueNAHO

Backport failed for release-25.11, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin release-25.11
git worktree add -d .worktree/backport-1721-to-release-25.11 origin/release-25.11
cd .worktree/backport-1721-to-release-25.11
git switch --create backport-1721-to-release-25.11
git cherry-pick -x a4ffbc20eabd1dd14ae43298ec58dd1c4bf1e874 25354cc88b67bede74dbf314949821889ae15e48 9afd8230cd8c92c0450f9f9ece65c05062160fc1 1272e6858e29205b8b03e696f121e6eedcb8b3b5 f7b554dea904393e483df9c13f0b6d6286d53ba7 76d05fd9c068d63f0dd747d40bcb8a4a57720daa 16df6b8448a856532b66ef8f7e012d29390d070b dfc859f54d937a31b954901ed01f3d6961cd2ead 953c3fb01e2a2cbfef092309852ba19d5ae6ee34 6153df31ce4f68f5709755994cc49c48d737e98c

stylix-automation[bot] avatar Dec 10 '25 14:12 stylix-automation[bot]