I’m pretty sure since we strictly have to merge all options before starting to evaluate the actual config object, this is the biggest linear factor we have in nixpkgs. Even if we figure out the spikes, the general linear trend will continue.
The solution to the growing number of module is clear to me: we have to mandate all modules to have an enable option as an entry point, and only import and evaluate them if they are enabled.
Existing modules loaded that do stuff unconditionally should be rewritten and enabled explicitely, only some exceptions for very basic setup should remain that way.
Thanks! A bit off-topic, but i wonder where this 7k options come from! I see a lot of _module present in the list generated form the nix expr that aren’t present in the options.json.br of the release
yes, not evaluating all modules is a great idea
we have some work to do to get there, though
the pam module is a good example of the work we need to do - the pam module references a ton of other modules
it would be nice if instead the other modules reference pam
a minimal.nix file containing a list of 185 modules that are required for building the toplevel of an (almost) empty nixos configuration.
This is only the first step and further work is required in order to improve the experience using nixosMinimal
right, an awesome first step! i’m convinced we can go much lower, though - just as a random example
./programs/seahorse.nix
currently i’m building my laptop with under 80 nix modules so we can definitely get there, just takes a bunch of refactoring to cleanly separate modules
very exciting work! thanks so much @DavHau and @lassulus for your efforts!
note that in this case i defined “nix module” as the result of find ./module-path -type f -name *.nix | wc -l
sorry if this is too off-topic, but i thought making imports dependent on config isn’t possible in the module system since it would cause an infinite recursion?
Right, but you can use ${modulesPath}/path/to/module.nix to explicitly import modules. Currently all the modules are imported. The idea here would be to not import them at all. Users would need to explicitly import them.
Since @Mic92 mentioned the flamegraphs in the nightly nix versions, I decided to make some!
I decided not to put the logs in the repo since they were too big and I didn’t feel like compressing it, but if you just drop into the devshell and run uv run nixpkgs-profiler.py, the logs will be generated.
The flamegraphs are in outputs/flamegraphs/*.svg.
Note that you need to drop into the devshell to have the logs generate, since the python script shells out to the nix version in PATH, and I was too lazy to create a derivation.
This might have some flake overhead compared to the original graphs, but I doubt it’ll be too big. I haven’t really looked at it at all.