!wfudwzqQUiJYJnqfSY:nixos.org

NixOS Module System

145 Members
29 Servers

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


SenderMessageTime
20 Jul 2025
@n4ch723hr3r:nope.chat@n4ch723hr3r:nope.chat *
          {
            name,
            ...
          }:
let
  ihnerit (config.flake.modules.x10.device-config.${name}) username;
in
          {
            options.homeManager = {
15:06:54
@n4ch723hr3r:nope.chat@n4ch723hr3r:nope.chathow about that?15:07:01
@n4ch723hr3r:nope.chat@n4ch723hr3r:nope.chat *
          {
            name,
            ...
          }:
let
  inherit (config.flake.modules.x10.device-config.${name}) username;
in
          {
            options.homeManager = {
15:07:07
@x10an14:matrix.orgx10an14 Gotcha. Just managed to put 2+2 together with your previous mention of fooConf.${name}. I got infinite recursion error 15:09:37
@n4ch723hr3r:nope.chat@n4ch723hr3r:nope.chatyeah i hope that makes sense why you got infinite recursion error15:10:34
@n4ch723hr3r:nope.chat@n4ch723hr3r:nope.chat* yeah i hope that it makes sense why you got infinite recursion error15:10:45
@x10an14:matrix.orgx10an14 I got it to work with lots of help from @mightyiam:matrix.org (thanks)! =) 17:11:02
@n4ch723hr3r:nope.chat@n4ch723hr3r:nope.chatnice what did you do?22:12:49
21 Jul 2025
@x10an14:matrix.orgx10an14

Something I'd already tried earlier but discarded due to an unrelated error (that I thought told me I could not do things this way):

{
    type =
      with lib.types;
      attrsOf (
        submodule (
          nixosConfig:
          let
            cfg = nixosConfig.config.nixos;
            inherit (nixosConfig.config) hostname username system;
          in
          {
            options.nixos = builtins.break {
              entryPoint = lib.mkOption {
                type = lib.types.path;
                default = "${repoRoot}/nixos/${username}_at_${hostname}";
              };
              toplevelBuild = lib.mkOption {
                type = lib.types.raw;
                readOnly = true;
              };
            };
            config.nixos.toplevelBuild = lib.mkIf (builtins.pathExists cfg.entryPoint) (
              inputs.nixpkgs.lib.nixosSystem {
                modules = [
                  {
                    nixpkgs.hostPlatform = { inherit system; };
                  }
                  (import cfg.entryPoint (inputs // { inherit repoRoot; }))
                  "${repoRoot}/x10/options/unfree-packages.nix"
                  inputs.nur.modules.nixos.default
                ];
                specialArgs = {
                  inherit inputs hostname repoRoot;
                };
              }
            );
          }
        )
      );
  }

So yeah, the inner config variable of the extending submodule contains the submodule's "sibling" option values.

07:14:28
@nbp:mozilla.orgnbp

x10an14: taking the discussion from the beginning …

If you want to declare options specific to one instance, you can do it as follow:

{ lib,  ... }@toplevel:
{
  config.flake.modules.foo.<fooInstance> = {config, ...}@submoduleInstance: {
    options.home-manager = lib.mkOption { ... };
    config.home-manager = ...;
  }
}

If you want to make the home-manager option available to all instances, then your initial example is almost there, you have to redefine the foo option with the submodule that you want to add. Submodule option declarations are merged, see fileSystems option as an example, which is declared in multiple modules.

09:36:22

Show newer messages


Back to Room ListRoom Version: 10