NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.58k stars 13.73k forks source link

Reorganize NixOS profile modules ("archetypes"?) #189840

Open roberth opened 2 years ago

roberth commented 2 years ago

Project description

Goals:

NixOS has its own definition for "profile", which is not to be confused by Nix's definition of "profile". Let's start by renaming "profile" to "archetype" to solve the ambiguity. EDIT: "preset" may be an even better term.

An archetype module is a module that contains configuration that goes into effect unconditionally. This is in contrast with most other modules, whose functionality is gated behind an "enable" option and a config = mkIf cfg.enable or similar. This is also in contrast with a "configuration module" which is managed by the user and is typically not intended for reuse (although I wouldn't complain if someone didn't call their reusable configuration module an archetype module).

Note that despite being classifiable by technical-ish means, these definitions do not exist within the implementation of the module system. They're entirely for us humans to characterize what is the purpose of a module.

Proposal:

  1. Create a new directory nixos/modules/archetypes and move all modules that consist of unconditional config to this directory.
  2. Split modules that contain both options and unconditional config, if the "options" logic can exist as regular modules without the unconditional config.

Future work:

  1. Refactor the archetypes to form a better hierarchy. Think of system characterizations like minimal, desktop, container, etc. I do not have an opinion on what should go where. Let's not blow up the scope of this issue. Step by step.
  2. Note that nixos-hardware also contains many archetypes. We may consider moving those as well, but I'll leave that out of scope as well for the time being.
rnhmjoj commented 2 years ago

archetype

Nix already comes with a fair share of obscure terms (derivation, instantiation, attribute set, channel), but NixOS has somehow managed to keep that down: there's basically just options, modules and types (let's ignore NIXOS_LUSTRATE for a moment here ;).

I'm sure this is subjective, but "archetype" (while being perfectly accurate, with access to a dictionary) feels really obscure. If the Nix/NixOS profile clash is a problem (personally I've never even realised this), I'd suggest to think of something more common. Maybe preset or template.

roberth commented 2 years ago

Template is also taken, but preset is a good candidate. It focuses more on the role of the module than how they're implemented, which is good. It's less differentiated from default which already has a specific meaning in modules but that could be a good thing as well, as they are closely related concepts.