Sometimes weird stuff happens that leads to NixOS config definitions not being what you expected. Commonly this is due to something somewhere in the NixOS modules that sets a higher priority than your definition, leading to it being shadowed. Tracking this down can be a nuisance. The best option that I’ve found is to use nix repl, load my NixOS config flake with :lf ., and then inspect the option through nixosConfigurations.<hostname>.options.<loc>, such as nixosConfigurations.<hostname>.options.networking.hostName. Whereas config only presents you the final value, options holds references to the definitions (even those that were overridden) as well as the highest priority level, which all serves to indicate where specifically the definition that trumped is located for further inspection. This works well for my case, but this doesn’t work for submodules.
Take for example nixosConfigurations.<hostname>.config.security.pam.services.sddm. Here you can see the final values just fine. But when your try to look for the definitions through nixosConfigurations.<hostname>.options.security.pam.services.sddm, it won’t be found since nixosConfigurations.<hostname>.options.security.pam.services is the root option, with sddm being an attribute submodule.
How can I get the option/evaluation information for the submodule? I remember at the beginning of the year when I was writing some modules myself that I had figured out how to do this, but I’ve since forgotten and can’t remember how. From what I remember you had to go through type.nestedType.elemType (which yields the submodule type) and then use getSubModules, getSubOptions, or substSubModules in some manner to get the submodule module details. I can’t piece it together and there is no documentation about this behaviour. I was deep into the types and modules Nixpkgs lib source code at the time, so I’m sure that’s where I figured out how to do this, but it’s been challenging to find what I need again.
Does anyone know how to do this? It would be greatly helpful.
I don’t think this is possible. Anything under type will only be returning the defaults for the submodule, not the actual settings. And nothing else available even seems likely to contain this information. It’s too bad, because I’d also like to see the submodule’s options value available somewhere.
These attrs are documented in https://nixos.org/manual/nixos/stable/#sec-option-types-custom. Unfortunately I don’t see how these will get you what you’re looking for, as they will help you list all of the generic submodule options, but they don’t help you inspect a specific submodule instance. In fact I don’t see anything here that would help - echoing the above from @tejing.
However, if you inspect options.security.pam.services.definitionsWithLocations you will at least get a list of all of the definitions (and the files they are defined in):