My objective is to have a smaller baseModules
passed to nixosSystem
and something similar for home-manager for faster evaluation times. I don’t want to manually pick the modules from nixpkgs to include, but rather have a script (that isn’t ran every rebuild, of course) that I can use to find out which nixpkgs modules my config is using.
I could only come up with the following method, which is probably not such a good one:
- Wrap all
baseModules
passed tonixosSystem
like this (or similarly):
# Assuming the module is a function, otherwise no need to wrap
let
mapConfig = lib.mapAttrsRecursive (path: value: lib.warn "-| ${lib.showOption path} |-" value);
in module: {
__functor = _: x: module (x // { config = mapConfig x.config; });
__functionArgs = lib.functionArgs module;
}
- Evaluate
system.build.toplevel
in a script and parse the warnings to find out which config options were evaluated as a “dependency” ofsystem.build.toplevel
. - Use
options.<the-option>.files
andoptions.<the-option>.declarations
to find out which files define and set the options found in step 2. - Make a list of
baseModules
containing only those files.
While this may work (I haven’t tried it), it sounds like a very bad solution.
Is there any better way to do something of the sort?
Thank you in advance for any help.