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

Add support for extraModules input #1301

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

oliverwiegers
Copy link

@oliverwiegers oliverwiegers commented Jan 27, 2025

NixOS offers the possibility to pass a list of extraModules to lib.nixosSystem which later gets merged with the modules list and baseModules.
This offers the possibility to read additional modules from environment variables, or a custom module-list.nix.

NixOS implementation is
here.

For nix-darwin an implementation was started in #592. I restarted the implementation and removed the usage of NIXOS_EXTRA_MODULE_PATH env variable because NixOS deprecated this one.

This is my first PR. Anything missing?

@oliverwiegers oliverwiegers force-pushed the master branch 2 times, most recently from 81f1989 to 168ff40 Compare January 27, 2025 15:00
NixOS offers the possibility to pass a list of extraModules to
lib.nixosSystem which later get merged with the modules list and
baseModules.
This offers the possibility to read additional modules from environment
files or a custom module-list.nix.

NixOS implementation is
[here](https://github.com/NixOS/nixpkgs/blob/8601973cec591ab18357eb7c26c52769d990d1ed/nixos/lib/eval-config.nix#L33).

Dor nix-darwin an implementation was started in LnL7#592.
I restarted the implementation and removed the usage of
`NIXOS_EXTRA_MODULE_PATH` env variable because NixOS deprecated this
one.
@oliverwiegers
Copy link
Author

@emilazy @Enzime I can't request a review. Is just opening the PR and waiting the way to go?

Let me know if you need anything from me :)

@emilazy
Copy link
Collaborator

emilazy commented Jan 30, 2025

I’d be okay doing this just on general NixOS interface compatibility grounds, but I’m curious what value it adds for you without the environment variable, since there’s no difference between setting extraModules and just adding things to modules?

@oliverwiegers
Copy link
Author

oliverwiegers commented Feb 4, 2025

@emilazy you're right it does not add any additional functionality without the environment variable. I would be happy to keep it, but I wanted to make it as close to the NixOS implementation as possible.

My main goal (should have stated this earlier) is to provide a way to separate different modules when invoking darwinSystem to make the function call more readable.
As an example: By having extraModules as an input I can put my configuration.nix and third party modules in the modules input and my custom modules in extraModules.

In short: Make ones personal config easier to read.

Does that make sense?

P.S. Using the variable would still be possible in a somewhat readable way:

lib.darwinSystem {
  ...
  modules = [configuration.nix];
  extraModules = [
    { imports = [ (builtins.getEnv "NIXOS_EXTRA_MODULE_PATH") ]; }
  ];
  ...
}

Which I think is more readable that putting both in modules

@oliverwiegers
Copy link
Author

@emilazy if this isn't something you would like to add you can close the PR 😊

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

Successfully merging this pull request may close these issues.

2 participants