hercules-ci / flake-parts

❄️ Simplify Nix Flakes with the module system
https://flake.parts
MIT License
721 stars 41 forks source link

Better naming `mkPerSystemOption` #142

Closed Atry closed 1 year ago

Atry commented 1 year ago

mkPerSystemOption barely creates an option of deferred module for documenting purpose. Shall we rename it to mkDeferredModuleOption? Since it is general-purposed, shall we upstream it to nixpkgs?

roberth commented 1 year ago

Submodules also support the static merging of a module, so we should then also have mkSubmoduleOption, although submodules tend not to appear as the type of an option, but rather as a type argument.

It would be nice if the module system could cast function syntax in options to the right option type using the explicitly declared options. I feel like that's a lot to ask of the module system's already stretched syntax, but it is very ergonomic:

{
  options.perSystem = { config, lib, system, ... }: {
    # it's a module that's statically known, so has docs
  };
}
{
  options.services.nginx.virtualHosts = virtualHostName: { config, ... }: {
    # a NixOS nginx plugin
    # note that `attrsOf` already passes `"<name>"` for static purposes
  };
}

Arguments against:

Arguments for:

Atry commented 1 year ago

I think we should allow for merging an option with its default values, no matter what the type is.

Atry commented 1 year ago

I created #145 for now, as Nixpkgs right now has not yet supported directly declared bare deferred module.

Atry commented 1 year ago

Fixed in #145