Skip to content

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

Merged
trueNAHO merged 10 commits intonix-community:masterfrom
trueNAHO:stylix-mk-target-polish-simplify-and-extend-interface
Dec 10, 2025
Merged

stylix/mk-target: polish, simplify, and extend interface#1721
trueNAHO merged 10 commits intonix-community:masterfrom
trueNAHO:stylix-mk-target-polish-simplify-and-extend-interface

Conversation

@trueNAHO
Copy link
Copy Markdown
Member

@trueNAHO trueNAHO commented Jul 18, 2025

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 a4ffbc20eabd1dd14ae43298ec58dd1c4bf1e874
Author: NAHO <90870942+trueNAHO@users.noreply.github.com>
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 25354cc88b67bede74dbf314949821889ae15e48
Author: NAHO <90870942+trueNAHO@users.noreply.github.com>
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 9afd8230cd8c92c0450f9f9ece65c05062160fc1
Author: NAHO <90870942+trueNAHO@users.noreply.github.com>
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 1272e6858e29205b8b03e696f121e6eedcb8b3b5
Author: NAHO <90870942+trueNAHO@users.noreply.github.com>
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 f7b554dea904393e483df9c13f0b6d6286d53ba7
Author: NAHO <90870942+trueNAHO@users.noreply.github.com>
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 76d05fd9c068d63f0dd747d40bcb8a4a57720daa
Author: NAHO <90870942+trueNAHO@users.noreply.github.com>
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 16df6b8448a856532b66ef8f7e012d29390d070b
Author: NAHO <90870942+trueNAHO@users.noreply.github.com>
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/vivid/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 ++++++++++++++++--------------
 108 files changed, 153 insertions(+), 151 deletions(-)

commit dfc859f54d937a31b954901ed01f3d6961cd2ead
Author: NAHO <90870942+trueNAHO@users.noreply.github.com>
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/vivid/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           |  9 +++++++--
 stylix/droid/default.nix            |  4 ++--
 stylix/hm/default.nix               |  9 +++++++--
 stylix/mk-target.nix                | 33 ++++++++++++++++-----------------
 stylix/nixos/default.nix            |  9 +++++++--
 stylix/overlays.nix                 |  2 +-
 108 files changed, 52 insertions(+), 327 deletions(-)

commit 953c3fb01e2a2cbfef092309852ba19d5ae6ee34
Author: NAHO <90870942+trueNAHO@users.noreply.github.com>
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 6153df31ce4f68f5709755994cc49c48d737e98c
Author: NAHO <90870942+trueNAHO@users.noreply.github.com>
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

v11: 6153df3

v10: 1bc50a2

v9: 0bfa746

v8: aa02968

v7: 4628b14

v6: c9a0103

v5: c0e8cde

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

v4: 90ca0a9

  • 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: eeac205

  • 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: dd5389a

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

v1: b311b35

  • 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: 176d421


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

@stylix-automation stylix-automation bot added topic: documentation Documentation additions or improvements topic: nixos NixOS target topic: home-manager Home Manager target topic: darwin nix-darwin target topic: droid Nix-on-Droid target topic: overlay Overlay changes labels Jul 18, 2025
@trueNAHO trueNAHO force-pushed the stylix-mk-target-polish-simplify-and-extend-interface branch 2 times, most recently from b311b35 to dd5389a Compare July 19, 2025 09:42
@trueNAHO trueNAHO mentioned this pull request Jul 19, 2025
5 tasks
@trueNAHO trueNAHO marked this pull request as draft July 19, 2025 11:37
@trueNAHO trueNAHO force-pushed the stylix-mk-target-polish-simplify-and-extend-interface branch from dd5389a to eeac205 Compare July 19, 2025 12:59
@trueNAHO trueNAHO marked this pull request as ready for review July 19, 2025 13:08
Copy link
Copy Markdown
Contributor

@Flameopathic Flameopathic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implementation looks good. 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.

@trueNAHO trueNAHO force-pushed the stylix-mk-target-polish-simplify-and-extend-interface branch 2 times, most recently from 90ca0a9 to c0e8cde Compare July 19, 2025 17:09
@trueNAHO
Copy link
Copy Markdown
Member Author

trueNAHO commented Jul 19, 2025

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.

@stylix-automation stylix-automation bot added the status: merge conflict Merge conflict label Jul 19, 2025
@0xda157
Copy link
Copy Markdown
Contributor

0xda157 commented Jul 19, 2025

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.

@trueNAHO trueNAHO force-pushed the stylix-mk-target-polish-simplify-and-extend-interface branch from c0e8cde to c9a0103 Compare July 19, 2025 21:51
@stylix-automation stylix-automation bot removed the status: merge conflict Merge conflict label Jul 19, 2025
@MattSturgeon
Copy link
Copy Markdown
Member

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.

@trueNAHO
Copy link
Copy Markdown
Member Author

trueNAHO commented Jul 20, 2025

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 #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 #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 #1212 (review), 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:

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

@stylix-automation stylix-automation bot added the status: merge conflict Merge conflict label Jul 27, 2025
Comment on lines +313 to +315
Settings merged with ${config}. Attribute sets are
recursively merged with ${config}, while all other
non-`null` types override ${config}.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Setting merged with config" this only applies to attrsets, I would just remove this part. also lib.stylix.colors is an internal impl detail that might be confusing to users here.

Copy link
Copy Markdown
Member Author

@trueNAHO trueNAHO Jul 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Setting merged with config" this only applies to attrsets, I would just remove this part.

Good point. This is resolved in v7.

lib.stylix.colors is an internal impl detail that might be confusing to users here.

AFAIK, people frequently use lib.stylix.colors, and exposing it here would partially resolve #208. It is only partially resolved because the mkTarget migration is incomplete.

@trueNAHO trueNAHO force-pushed the stylix-mk-target-polish-simplify-and-extend-interface branch from c9a0103 to 4628b14 Compare July 30, 2025 16:42
@trueNAHO trueNAHO force-pushed the stylix-mk-target-polish-simplify-and-extend-interface branch from aa02968 to 0bfa746 Compare November 21, 2025 20:32
Copy link
Copy Markdown
Contributor

@0xda157 0xda157 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code LGTM, my config builds when overriding stylix with this branch

Tested-by: 0xda157 <da157@voidq.com>

@0xda157 0xda157 requested review from danth and removed request for MattSturgeon November 21, 2025 20:43
@trueNAHO
Copy link
Copy Markdown
Member Author

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.

@stylix-automation stylix-automation bot removed the status: merge conflict Merge conflict label Nov 21, 2025
@trueNAHO trueNAHO force-pushed the stylix-mk-target-polish-simplify-and-extend-interface branch from 0bfa746 to 1bc50a2 Compare November 21, 2025 21:46
@stylix-automation stylix-automation bot added the status: merge conflict Merge conflict label Nov 21, 2025
Copy link
Copy Markdown
Contributor

@0xda157 0xda157 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@trueNAHO go ahead and rebase this and merge it

Fixes: 093087e ("stylix: add imports to mkTarget (nix-community#1363)")
Rename the mkConfig function to callModule to generalize the name beyond
the specific config and options module arguments.

Fixes: dea0337 ("stylix: restrict access to config while using mkTarget (nix-community#1368)")
Polish the mkTarget implementation to improve error reporting and
simplify future enhancements.

Configuration elements can now recursively resolve to paths.
Rename the generalConfig argument to unconditionalConfig to better imply
the intentional lack of safeguarding.
Rename mkTarget's 'configElements' argument to 'config' and
'extraOptions' to 'options' to provide a more transparent interface with
the underlying Nixpkgs module system.
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: nix-community#1661
Generate targets.${target}.${argument}.enable and
targets.${target}.${argument}.override options for disabling and
configuring safeguarded arguments on a target level.
Normalize the options argument identically to config to provide a
coherent and extensible options interface.
@trueNAHO trueNAHO force-pushed the stylix-mk-target-polish-simplify-and-extend-interface branch from 1bc50a2 to 6153df3 Compare December 10, 2025 14:11
@trueNAHO trueNAHO added backport: release-25.11 To be backported to the release-25.11 stable branch and removed backport: release-25.05 labels Dec 10, 2025
@trueNAHO trueNAHO merged commit 54fcd2f into nix-community:master Dec 10, 2025
10 checks passed
@stylix-automation
Copy link
Copy Markdown
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport: release-25.11 To be backported to the release-25.11 stable branch status: merge conflict Merge conflict topic: darwin nix-darwin target topic: documentation Documentation additions or improvements topic: droid Nix-on-Droid target topic: home-manager Home Manager target topic: modules /modules/ subsystem topic: nixos NixOS target topic: overlay Overlay changes topic: stylix /stylix/ subsystem

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants