Skip to content
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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

roberth
Copy link
Contributor

@roberth roberth commented Jul 21, 2023

Experimental changes I made while trying to render docs and maybe figure out how to use it in a "consumer" flake-parts based flake.

@@ -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 =
Copy link
Contributor Author

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"; };
Copy link
Contributor Author

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 ({
Copy link
Contributor Author

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);
Copy link
Contributor Author

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; }

@DavHau
Copy link
Member

DavHau commented Jul 26, 2023

Merged the first commit via #597
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants