Submodule with list argument

Hi all,

I tried understanding the systemd utility functions in nixpkgs and found this code: https://github.com/NixOS/nixpkgs/blob/91a3819bad39f4a9d8cba7ee2458fd3adab12195/nixos/lib/systemd-types.nix#L14-L36

I am confused that the argument to submodule is a list. The documentation states it should be a function or a set: NixOS 23.11 manual | Nix & NixOS

Could someone elaborate what the code does? Is it just merging the elements of the list and using it as the set?

Thanks!

1 Like

Oh no, the docs are outdated. It does support lists indeed. The semantics are that

types.submodule [ a b c ]

is the same as

types.submodule {
  imports = [ a b c ];
}
1 Like

Oh, I see! Great, thanks!

I submitted a PR. Not sure the wording is great, accepting suggestions.

https://github.com/NixOS/nixpkgs/pull/199281

2 Likes

That’s awesome thanks!