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

How to define a custom flake attribute for a reusable module #201

Closed
loqusion opened this issue Dec 24, 2023 · 2 comments
Closed

How to define a custom flake attribute for a reusable module #201

loqusion opened this issue Dec 24, 2023 · 2 comments

Comments

@loqusion
Copy link

I'm trying to add a custom option lib to my reusable flake module, and here's what the documentation has to say about it (emphasis added):

If your custom output attribute is a one-off because you need to do something special in a single project, all you have to do is define a value in the flake option.

However, if you want it to be reusable and integrate well, you should declare an option for it, and you could perhaps provide a bit of support logic if that makes sense to do.

However, this piece of documentation does not answer the question "how do I declare an option?", nor does it provide a link doing so. Looking through the rest of the documentation also does not provide any obvious answers.

It would be very helpful if a link that answers this question were present in this text, something like:

If your custom output attribute is a one-off because you need to do something special in a single project, all you have to do is define a value in the flake option.

However, if you want it to be reusable and integrate well, you should declare an option for it, and you could perhaps provide a bit of support logic if that makes sense to do.

Or, alternatively, provide a code snippet that demonstrates how to do so.

@bew
Copy link

bew commented Dec 25, 2023

Why close? Did you find documentation?
I'm kinda blocked as well around this topic of "how to actually do a module"

@terlar
Copy link

terlar commented Dec 25, 2023

This shows an example on how to define a custom option that will put things under the root flake.

https://github.com/hercules-ci/flake-parts/blob/main/modules/nixosModules.nix#L14

You can use the mkSubmoduleOptions from flake-parts-lib.

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

No branches or pull requests

3 participants