-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Feature request: Flake templates with variables #4017
Comments
I marked this as stale due to inactivity. → More info |
I tried using a function on the path attr of the template and a function enclosing each template. The |
I'd also like to parameterise templates. Here's the example that lead me to this issue:
I'd prefer to avoid hard-coding the value for In my imagination, this command would result in the above template:
|
Related: https://github.com/NixOS/templates |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/usability-study-session-2/21400/1 |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/fleek-user-friendly-home-manager/27150/12 |
Summarizing and adding ideas + some opinion. Basically
|
Or maybe just allow it to be a function that outputs a derivation that can be impure but it will deep copy $out to the destination directory. Seems more useful and people can use any language that nix can support. |
Is your feature request related to a problem? Please describe.
When we create a new project from a flake template with something like:
the generated project is fixed, and cannot depend on any configuration variable specified by the user. I'd love to be able to be able to specify some variables, like the name of the project, the description of the project, the licence of the project... and then let a template engine create the good files/files content (both of them could depend on the variable names) automatically.
Describe the solution you'd like
There are two solutions I can think of, which are maybe not mutually exclusive and could benefit from each other:
npm init
to create a npm project. We could therefore turn anix flake init
into anix run
.I think that both solutions should be used: the first one (based on cookiecutter or alike) provides an easy to use syntax for users that do not care about advanced template generation, and the second option allow more advanced code generator to be used.
Describe alternatives you've considered
For now, I'm using instead
nix run
to do what I need:The text was updated successfully, but these errors were encountered: