Skip to content

Conversation

@0xda157
Copy link
Contributor

@0xda157 0xda157 commented Dec 6, 2025

Link: https://github.com/nix-community/stylix/issues/1651

@stylix-automation stylix-automation bot added topic: modules /modules/ subsystem topic: stylix /stylix/ subsystem labels Dec 6, 2025
@0xda157 0xda157 force-pushed the firefox-per-profile branch 2 times, most recently from 58ef0d1 to 7195791 Compare December 6, 2025 21:10
@0xda157 0xda157 force-pushed the firefox-per-profile branch from 7195791 to 9e5c499 Compare December 6, 2025 21:19
@stylix-automation stylix-automation bot added the topic: testbed Testbed changes label Dec 6, 2025
@0xda157 0xda157 force-pushed the firefox-per-profile branch 4 times, most recently from 1289331 to bc78620 Compare December 6, 2025 22:27
@0xda157
Copy link
Contributor Author

0xda157 commented Dec 6, 2025

I'm currently stuck on the below error, which doesn't make any sense:

«error: The option `virtualisation.vmVariant.home-manager.users.guest.options' does not exist. Definition values:
- In `/nix/store/a8sgh5vpac9nqszdp1ddma472ih9dmfv-source/modules/firefox/each-config.nix'»

@MattSturgeon
Copy link
Member

I'm currently stuck on the below error, which doesn't make any sense:

«error: The option `virtualisation.vmVariant.home-manager.users.guest.options' does not exist. Definition values:
- In `/nix/store/a8sgh5vpac9nqszdp1ddma472ih9dmfv-source/modules/firefox/each-config.nix'»

This error is typically caused by shorthandOnlyDefinesConfig in submodule option types:

https://nixos.org/manual/nixos/unstable/#sec-option-types-submodule

When shorthandOnlyDefinesConfig = true (the default for types.submodule), an attribute named options is interpreted as defining an option literally called options — shorthand for config.options — rather than declaring option definitions. So if a submodule contains:

options = {};

the module system believes you are defining the option:

virtualisation.vmVariant.home-manager.users.guest.options

which doesn’t exist, leading to the error you’re seeing.

A common workaround is to use a module form that isn’t a plain attribute set, e.g.:

  • function-shaped modules:

    _: { options = {}; }
  • file-path modules (./file-module.nix)

which disable the shorthand behavior, or to use types.submoduleWith if you can control the submodule type.

@MattSturgeon
Copy link
Member

Although, if that's a home-manager configuration, I don't think it uses shorthandOnlyDefinesConfig. IIRC.

Is Home Manager's NixOS module imported into the virtualisation.vmVariant submodule? Assuming that even is a NixOS configuration submodule?

Comment on lines 137 to 146
`submodule` (Module -> Module)
: A function which transforms a module into a submodule, for example:
```nix
module: {
options.programs.firefox.profiles = lib.mkOption {
type = lib.types.attrsOf (lib.types.submodule module);
};
}
```
Copy link
Member

Choose a reason for hiding this comment

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

I did not really read the diff, but is there no way around extending the Stylix module system by using existing functionality? It would be sad to increase its complexity unless absolutely necessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did not really read the diff, but is there no way around extending the Stylix module system by using existing functionality? It would be sad to increase its complexity unless absolutely necessary.

I have an alternative solution which should make the diff on /stylix/mk-target.nix very small, but I don't have time to implement it this week.

Copy link
Contributor Author

@0xda157 0xda157 Dec 12, 2025

Choose a reason for hiding this comment

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

I've implemented the alternative solution and it basically doesn't work. mkTarget need to access to config from the top-level so as far as I can tell the only way to do it is by passing some submodule function.

Copy link
Member

@trueNAHO trueNAHO Dec 12, 2025

Choose a reason for hiding this comment

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

After backtracking conversations, I do not fully understand what is going on and can therefore not really help. Specifically, I do not understand how the end-user interface is supposed to change and how this should be implemented.

IIUC, the issue is that extending profile declarations with Stylix theming currently requires explicitly declaring profiles to be extended such that the following application is possible:

stylix.targets.${target}.profileNames = ["one" "two" "three"];

programs.${program}.profiles =
  lib.genAttrs config.stylix.targets.${target}.profileNames /* ... */;
  1. Why can we not simply extend all submodules by iterating over them, or does this lead to infinite recursion?

  2. IIUC, the proposal is also about adding top-level stylix.${target}.profiles.${profile}.enable options to potentially disable theming for certain profiles. If the already defined Home Manager submodule can be extended, would it not be better to add this option under stylix.targets.${target}.profiles.${profile}.enable or programs.${program}.profiles.${profile}.stylix.enable?

Considering all of this, why does mkTarget need to interface a "submodule"? If this is just to declare options outside the default stylix.targets.${target} namespace, then this should already be possible by declaring them inside imports.

@0xda157 0xda157 marked this pull request as draft December 9, 2025 23:11
@stylix-automation stylix-automation bot added the status: merge conflict Merge conflict label Dec 10, 2025
@0xda157 0xda157 force-pushed the firefox-per-profile branch from bc78620 to 0d53b78 Compare December 12, 2025 01:11
@stylix-automation stylix-automation bot added the topic: home-manager Home Manager target label Dec 12, 2025
@stylix-automation stylix-automation bot removed the status: merge conflict Merge conflict label Dec 15, 2025
@stylix-automation stylix-automation bot added the status: merge conflict Merge conflict label Jan 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: merge conflict Merge conflict topic: home-manager Home Manager target topic: modules /modules/ subsystem topic: stylix /stylix/ subsystem topic: testbed Testbed changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants