-
-
Notifications
You must be signed in to change notification settings - Fork 127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide flake parts module #597
base: main
Are you sure you want to change the base?
Provide flake parts module #597
Conversation
@@ -31,7 +31,13 @@ in { | |||
}; | |||
|
|||
# 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes the options statically available for rendering.
@@ -9,10 +9,25 @@ | |||
in { | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.