Where to find docs on structure of realised/merged system config // accessing systemConfig in HM build function (flake)

While refactoring my multi-host/multi-user/multi-profile system and HM flake (an evolution on the struggles documented here), I figured I might as well generate the <user>@<host> outputs for homeConfigurations from the current realised system config.

For that I wanted to do something like

   systemusers = lib.attrsets.mapAttrs (n: v: v.config.users.users) inputs.self.nixosConfigurations;

and then “map/filter” my way to generating all combinations of <user>@<hostname> that will make up the attribute set for the homeConfigurations = { ... } output.

The issue: when I try the above access to v.config.... I get a strange error:

error: anonymous function at /nix/store/kacay40ndc0mwqdqlfp88fzl3lzh8w53-source/pkgs/build-support/fetchurl/boot.nix:5:1 called with unexpected argument 'postFetch'

       at /nix/store/kacay40ndc0mwqdqlfp88fzl3lzh8w53-source/pkgs/build-support/fetchpatch/default.nix:31:1:

           30| in
           31| lib.throwIfNot (excludes == [] || includes == [])
             | ^
           32|   "fetchpatch: cannot use excludes and includes simultaneously"

EDIT: The above error seems to be related to nix eval (which I’m using to test my flake incrementally before actually building derivations) (see here and here), but the below question is still current (though I could of course do more trial & horror).

I’m not at all sure whether it is the correct attribute path though (although it doesn’t complain about a missing attribute), but I can’t seem to find documentation of the structure of the merged config; it doesn’t appear to be the same as how it appears in configuration.nix.

Oh wait, it doesn’t seem to be all that bad (the trial & horror that is), one can test the flake incrementally by doing something like:

outputs = ....
   test2 = (nixpkgs.lib.attrsets.mapAttrs (n: v: v.config) inputs.self.nixosConfigurations);

and then in nix repl (@ipetkov thanks for these tips)

:lf .

actually lists the users.

1 Like