NixOS Module System | 152 Members | |
| 32 Servers |
| Sender | Message | Time |
|---|---|---|
| 29 May 2025 | ||
| 22:09:24 | ||
| So, hi! I'm working on a thing to let me write home-manager homes that can be either used independently or attached to NixOS systems... my homes look like some attrset of ... attaching the home modules to a home-manager NixOS home is fairly straightforward, I can write some code that looks a little like this to generate some NixOS modules that put everything where I want it to go ...
unfortunately, not so with setting the special args. Home-manager's NixOS module has a way to do this: home-manager.extraSpecialArgs, but it's not per-user so if I attach multiple homes that would cause issues. I tried setting ...I wondered about merging in some options that defined more specialArgs, since as in NixOS a home-manager module is a submoduleWith and I know those can be merged. Unfortunately, it's actually an ...the comment above that seems to suggest that's because it w | 22:24:26 | |
| * So, hi! I'm working on a thing to let me write home-manager homes that can be either used independently or attached to NixOS systems... my homes look like some attrset of ... attaching the home modules to a home-manager NixOS home is fairly straightforward, I can write some code that looks a little like this to generate some NixOS modules that put everything where I want it to go ...
unfortunately, not so with setting the special args. Home-manager's NixOS module has a way to do this: home-manager.extraSpecialArgs, but it's not per-user so if I attach multiple homes that would cause issues. I tried setting ...I wondered about merging in some options that defined more specialArgs, since as in NixOS a home-manager module is a submoduleWith and I know those can be merged. Unfortunately, it's actually an ...the comment above that seems to suggest that's because it would be ambiguous | 22:24:36 | |
| https://github.com/NixOS/nixpkgs/blob/f880c595eafbd35ed066f0a8097409cb79188798/lib/modules.nix#L822
I want option A here I think - but I'm not sure what it's syntax sugar for... does anyone know what this is syntax sugar for and/or does anyone else have a pointer to how I might be able to set these specialArgs for only a single home-manager user | 22:25:52 | |
| * https://github.com/NixOS/nixpkgs/blob/f880c595eafbd35ed066f0a8097409cb79188798/lib/modules.nix#L822
I want option A here I think - but I'm not sure what it's syntax sugar for... does anyone know what this is syntax sugar for and/or does anyone else have a pointer to how I might be able to set these specialArgs for only a single home-manager user? | 22:26:00 | |
| 30 May 2025 | ||
| Apologies if I missed anything, but why do you need to set If you just want extra module args, you can usually use the If you just need to pass some value from another scope into a modules (e.g. to access
You could always declare these options within the submodule rather than merging them in by declaring them in the outer module eval. If you do this in a module that is defined within a file with access to the args you want, then you shouldn't need to do anything fancy. That said, these wouldn't be "special" because they'd be configured within the submodule eval, but that's no different to a merged-in option declaration. * it is the fact that these args are defined outside of the module system eval that makes them "special". | 00:58:12 | |
| If you want an option to be available for a single user, this should be as simple as:
Where the module declares the option you want to see available for this user only. Submodules are literally modules, following the same shortcuts that | 09:36:55 | |
| I think I maybe misphrased my question, sorry, this was supposed to all be about getting args into the module... the tangent with the options was one way I'd tried to do this i.e. literally taking another when I tried setting my example is kinda convoluted at the moment - but I'll see if I can get something more minimal to send here... | 20:54:40 | |
| Without getting too much into the weeds, infinite recursion can show up for a number of reasons. Not just defining imports via a config value (such as non-special args). For example, trying to use an arg that doesn't exist usually shows up as infinite recursion too. E.g. if you were defining or using args in mismatched module evals. As for "merging in" special args; this isn't really possible because the whole point of special args is that they aren't defined by the module system. Is there a reason you need different args per user instead of using home-manager's shared | 21:02:00 | |
In reply to @mattsturg:matrix.org
Yeah, I've definitely seen this... the way I'm doing it at the moment is generating a list of modules for my NixOS config, including both modules that set home-manager user modules up and modules that set
gotcha - yeah... the special args are defined in NixOS and I have what I want them to be for the homes in NixOS. If I could merge in a different type for each attr of the attrsOf I think I could do it, since as I could merge in another submodule that has the specialArgs I want ... unfortunately it's pretty much all or nothing there
it's a pretty artificial constraint, but I'm not making the structure for homes themselves - so I can't guarentee that there aren't conflicting home args set in different homes ... I'm trying to make a thing that can be used to take standalone home-manager homes and put them in nixos systems - and the individual standalone home-manager home spec I have here doesn't share special args... what I'm trying to do is mostly plumbing, I hadn't considered seeing if I could get the home spec modified to better fit this case (or just, you know, ban setting these to different things) | 23:06:28 | |
| I'd strongly consider discouraging I appreciate E.g. this module uses
This one has access to
| 23:33:23 | |
| 31 May 2025 | ||
| Sorry if I was dismissive before, I'm fresh with coffee now! 😁
Well, in that example the
I would try a simple example; define two modules for the same user. One defining module args, the other trying to use them in some non-recursive way.
I was over-simplifying when I said this; because the submodule with the special args you're setting is a separate module eval, you are still defining them outside that module eval. However IDK if the submodule type supports type-merging them. e.g. if you declared a duplicate option with additional special args in its I.e. in some cases you can declare the same option twice, and the module system will merge those declarations (not definitions!). This is kinda black magic though, and only supports merging certain aspects of options. Most of the time you'll get an "option declared multiple times" error. If you really do need this and none of the alternative approaches I suggested are sufficient, I would suggest sending a PR to home-manager which adds a "per-user" The existing Such an option might look like:
Feel free to ping me in any relevant PRs. | 08:28:37 | |