Provide flake parts module - #597
Conversation
|
|
||
| # generates future flake outputs: `modules.<kind>.<module-name>` | ||
| config.flake.modules = lib.mapAttrs (kind: _: mapModules kind) moduleKinds; | ||
| config.flake.modules = |
There was a problem hiding this comment.
I've assumed that this was for internal purposes, and I think it would make sense to have something like this in flake-parts for publishing modules.
It would also be nice to have an option for local modules that aren't published.
| let modules = lib.mapAttrs (kind: _: mapModules kind) moduleKinds; | ||
| in modules // { | ||
| flake-parts = modules.flake-parts // { | ||
| all-modules = { imports = flakePartsModules; _class = "flake-parts"; }; |
There was a problem hiding this comment.
Kinds are actually called class in evalModules or _class in the module syntax.
It's a fairly new thing, not too long before 23.05. https://nixos.org/manual/nixpkgs/stable/#module-system-lib-evalModules-param-class
Haven't used class much yet as it's incompatible with 22.11, but that's increasingly no excuse anymore ;)
| { | ||
| perSystem = { | ||
| { flake-parts-lib, ... }: { | ||
| options.perSystem = flake-parts-lib.mkPerSystemOption ({ |
There was a problem hiding this comment.
This makes the options statically available for rendering.
| options.writers = { | ||
| writePureShellScript = lib.mkOption { | ||
| type = lib.types.functionTo lib.types.anything; | ||
| type = lib.types.functionTo (lib.types.functionTo lib.types.package); |
There was a problem hiding this comment.
I've moved the documentation here, but probably the option declarations should be moved closer to the writers.
Sort-of like this:
options.writers = lib.mkOption { type = submodule ../writers.nix; }|
Merged the first commit via #597 |
Experimental changes I made while trying to render docs and maybe figure out how to use it in a "consumer" flake-parts based flake.