Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thin nixosSystems #122

Open
zimbatm opened this issue Apr 14, 2023 · 3 comments
Open

Thin nixosSystems #122

zimbatm opened this issue Apr 14, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@zimbatm
Copy link
Member

zimbatm commented Apr 14, 2023

Is your feature request related to a problem? Please describe.

When calling nixpkgs.lib.nixosSystems, all the NixOS modules of the repo are getting loaded, making the evaluation quite expensive.

Describe the solution you'd like

Provide a compatible function that only loads a subset of the nixpkgs NixOS modules.

Describe alternatives you've considered

Additional context

@zimbatm zimbatm added the enhancement New feature or request label Apr 14, 2023
@soupglasses
Copy link

Do you know where nixpkgs.lib.nixosSystems causes the full loads? Would very likely help narrow down what needs modified.

@phaer
Copy link
Member

phaer commented Aug 22, 2023

Do you know where nixpkgs.lib.nixosSystems causes the full loads? Would very likely help narrow down what needs modified.

I believe that starts with baseModules ? import ../modules/module-list.nix in https://github.com/NixOS/nixpkgs/blob/9d757ec498666cc1dcc6f2be26db4fd3e1e9ab37/nixos/lib/eval-config.nix#L22

There's https://github.com/NixOS/nixpkgs/blob/master/nixos/lib/eval-config-minimal.nix which does not evaluate all the modules by default, but I haven't succeeded in building an actual nixosSystem with that as the modules are currently rather tightly coupled.

E.g. I want systemd-resolved for my system, but that module currently checks if config.network-manager.enable is true and just fails to evaluate if that option isn't even defined (because I do not need network-manager and therefore did not load the module).

That alone would be easy to solve, but as I have no idea how many similar evaluation errors would follow, I did not continue to investigate further. Happy to work on this together during NixCon or Oceansprint if interested people are there! :)

One idea would be to start with tooling that calculates the "dependency tree" of modules, not in terms of imports, but in terms of references to config.${name} in order to get an idea of what needs to be done and where the quickest wins can be found.

@arianvp
Copy link
Member

arianvp commented May 23, 2024

I've been on a similar quest:

https://github.com/arianvp/lolmin/blob/main/flake.nix

All the modules that I moved out of nixpkgs into my own repo are problematic ones. Which I then kept deleting lines from until it stopped complaining about dependencies.

pam.nix basically pulls in the world. It's a really problematic module.

network-interfaces.nix pulls in basically every network manager and tool in existance whilst you really only need networking.hostName

wrappers.nix pulls in sudo-rs and apparmor and co.

systemd-initrd pulls in the old initrd module
journald pulls in rsyslogd and syslog-ng

Anyhow. Eval went from 6s to 3s which is quite nice. But it shows NixOS needs a lot of refactoring for it to be practically possible to reduce the module list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants