-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Description
Description
When using NixOS with flakes, all referenced inputs are fetched eagerly, even if only a subset of their modules are actually used. This makes it impossible to avoid downloading large or optional module trees (e.g. desktop environments, vendor modules) when they are not needed for a given configuration.
This becomes especially problematic for:
- Large flakes that expose many optional modules
- Users on limited or offline environments
- CI systems where minimizing network access and evaluation time matters
Currently, there is no way to declare that certain modules should be ignored entirely at the flake level, even if they are present in inputs.
Proposed feature
Introduce a flake-level option that allows users to explicitly ignore specific modules, preventing them from being fetched or evaluated.
Example (illustrative syntax):
{
inputs.nixpkgs.url = "github:NixOS/nixpkgs";
outputs = { self, nixpkgs, ... }: {
nixosConfigurations.myHost = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
./configuration.nix
];
# Proposed option
ignoreModules = [
./modules/gnome.nix
./modules/kde.nix
# and the list goes on
];
};
};
}The intent is that ignored modules are:
- Not downloaded
- Not evaluated (optional)
- Not considered during module resolution
Expected behavior
- References to ignored modules should result in a clear, actionable error
- Behavior should be deterministic and cache-friendly
Additionally, ignored modules should be re-enabled automatically when rebuilding with an explicit CLI flag (e.g. --stop-ignore). This would allow users to temporarily opt out of ignoreModules for full rebuild.
Why this belongs in Nix
This feature would improve build times and reduce unnecessary bandwidth usage for nixpkgs servers, while giving users more explicit control over evaluation and fetching behavior in flake-based NixOS configurations.