!wfudwzqQUiJYJnqfSY:nixos.org

NixOS Module System

143 Members
28 Servers

You have reached the beginning of time (for this room).


SenderMessageTime
27 May 2025
@deeok:matrix.orgmatrixrooms.info mod bot (does NOT read/send messages and/or invites; used for checking reported rooms) joined the room.15:31:38
29 May 2025
@minion3665:nixos.devSkyler joined the room.22:09:24
@minion3665:nixos.devSkyler

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 { modules = [ ... ]; args = { ... }; }, args being some specialArgs provided to home-manager normally ...

... 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 ...

map (module: {
  home-manager.users.${username} = module;
}) home.modules;

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 _module.args but (1) was getting infinite recursion when I tried to use any of the new args, and (2) that is a little different from how home-manager standalone is consuming the args, and I'd prefer to avoid inconsistencies if at all possible...

...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 attrsOf submoduleWith, so I can't merge into home-manager.users.${username} or I get this "would be a parent of the following options but its type does not support nested options" error...

...the comment above that seems to suggest that's because it w

22:24:26
@minion3665:nixos.devSkyler *

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 { modules = [ ... ]; args = { ... }; }, args being some specialArgs provided to home-manager normally ...

... 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 ...

map (module: {
  home-manager.users.${username} = module;
}) home.modules;

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 _module.args but (1) was getting infinite recursion when I tried to use any of the new args, and (2) that is a little different from how home-manager standalone is consuming the args, and I'd prefer to avoid inconsistencies if at all possible...

...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 attrsOf submoduleWith, so I can't merge into home-manager.users.${username} or I get this "would be a parent of the following options but its type does not support nested options" error...

...the comment above that seems to suggest that's because it would be ambiguous

22:24:36
@minion3665:nixos.devSkyler

https://github.com/NixOS/nixpkgs/blob/f880c595eafbd35ed066f0a8097409cb79188798/lib/modules.nix#L822

          # Raw options can only be merged into submodules. Merging into
          # attrsets might be nice, but ambiguous. Suppose we have
          # attrset as a `attrsOf submodule`. User declares option
          # attrset.foo.bar, this could mean:
          #  a. option `bar` is only available in `attrset.foo`
          #  b. option `foo.bar` is available in all `attrset.*`
          #  c. reject and require "<name>" as a reminder that it behaves like (b).
          #  d. magically combine (a) and (c).
          # All of the above are merely syntax sugar though.

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

Show newer messages


Back to Room ListRoom Version: 10