to pass specialArgs to my sub-module that I import. Now, I'd like to take it a step further and import a list of paths from specialArgs.suitesand passspecialArgs` itself to it for each of them.
That’s not really how you do it, the arguments to the modules are automatically supplied when you add them to imports, you are not supposed to do this yourself. What you are doing will also break down if you don’t list all required arguments for every dependent module down the import tree in the parent modules, so it really doesn’t scale.
How I’d do this (to the extent that I understood what you’re trying to do):
In suites.nix:
# No need to specify the args here if they are not used in this module.
# You could even leave of this first line entirely.
{ ... }:
{
imports = [
./suites/base.nix
./suites/devel.nix
];
}
And then either of the other two modules, can still take any module arguments that you want:
# suites/base.nix
{ config, pkgs, lib, ... }:
{
# You can use config, pkgs, and lib here
}
The whole point of the module system is to manage how to call and merge the modules, so that you don’t need to do this manually, which would quickly become a huge pain.
So my specialArgs are simply passed down automatically. @R-VdP The reason why I don’t want to define all suites in suites.nix is, because I want to select suites for each host individually.
In the attempt to make it cleaner, I just made it more complicated. I should just remove suites.nix and pass all my suites into modules within my flake and call it a day. Thanks a lot.
Yeah, in that case you could indeed just cut out the middle man.
Alternatively, you can define options to selectively enable/disable modules, and for every host set the options concerning the required modules to true, just like how it’s done in NixOS (things like services.openssh.enable = true;).
This would work well if you want to have more fine-grained control than what you can do with only controlling top-level imports.
That sounds cool and I will learn how to do this sooner or later, but as I’m new to NixOS, I will focus on keeping my configuration very easy to understand to get familiar. Thanks for the quick help.