Skip to content

feat: support generating flake.nix via --flake - #834

Open
ArisoN-ext wants to merge 1 commit into
nix-community:mainfrom
ArisoN-ext:flake-generate
Open

ArisoN-ext wants to merge 1 commit into
nix-community:mainfrom
ArisoN-ext:flake-generate

Conversation

@ArisoN-ext

Copy link
Copy Markdown
  • Add --flake CLI argument and flake configuration file option
  • Generate a minimalistic flake.nix template in the output directory
  • Format the generated file automatically using the configured formatter

- Add `--flake` CLI argument and `flake` configuration file option
- Generate a minimalistic `flake.nix` template in the output directory
- Format the generated file automatically using the configured formatter

@figsoda figsoda left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is too opinionated imo, there isn't one convention to make a flake

nix-init is only supplying the description here, you can probably just run cp or something like that in addition to nix-init

@ArisoN-ext

ArisoN-ext commented Jul 20, 2026 •

Copy link
Copy Markdown
Author

this is too opinionated imo, there isn't one convention to make a flake

nix-init is only supplying the description here, you can probably just run cp or something like that in addition to nix-init

The flake is primarily here for convenience. Using nix-init to run programs through a flake is much more convenient. And since flake code style is somewhat subjective — which I agree with. I've kept this one as minimalistic as possible

@s0me1newithhand7s

Copy link
Copy Markdown

this is too opinionated imo, there isn't one convention to make a flake

there is a thin balance between heavy flake-part / blueprint usage and simple basic flake with 1 input and handful of outputs, which, imo this PR handles; we are getting a playground to expand but also ready-to-use, not a literal blueprint, neither a blank nix flake init output. hence... why not?

@figsoda

figsoda commented Jul 25, 2026

Copy link
Copy Markdown
Member

And since flake code style is somewhat subjective — which I agree with. I've kept this one as minimalistic as possible

choosing to be minimalistic here is itself subjective, and this is one of the decisions that i don't want nix-init to make

there is a thin balance between heavy flake-part / blueprint usage and simple basic flake with 1 input and handful of outputs, which, imo this PR handles

i think finding a balance is being opinionated, what is the right balance is up to personal preference

even if we agree on being minimalistic / not using stuff like flake-parts, there are still a lot of small decisions to make, nixos-unstable vs nixpkgs-unstable, whether to include a description, whether the package should be under default or the package name, and even smaller formatting preferences: ?ref= vs /, let inherit vs qualifying, that aren't covered by the formatter

nix-init is by no means completely opinionated, i try my best to follow the consensus on things, but there are some things (e.g. where __structuredAttrs should be,) that simply don't have a consensus, and i have to make a choice, but they are essential features that nix-init is made to support, whereas the --flake option can mostly be replaced with a cp command, and it takes very little effort to create a nix-init-flake command that just runs nix-init along with the cp command, where anyone can personalize the flake to their own preferences

@AZMCode

AZMCode commented Nov 12, 2026 •

Copy link
Copy Markdown

@figsoda

this is too opinionated imo
choosing to be minimalistic here is itself subjective, and this is one of the decisions that i don't want nix-init to make
the --flake option can mostly be replaced with a cp command, and it takes very little effort to create a nix-init-flake command

If I may butt in here in defense of flake support:

The general point of a program being unopinionated in software development is not to force the user into a desicion they don't want to make.

That way software stays extensible, and intercompatible, and headaches are avoided.

This program, in particular, is a boilerplate generation tool, essentially.

The user is never going to be stuck with code they don't want to use, because they can just change it if they so wish.

Now, to make those changes convenient and unintrusive, which is what I think a boilerplate tool should strive to do, it should be as minimal as possible. The particular outcome of choices that need to be taken to provide such a minimal starting point are not nearly as relevant as the fact that they are taken, and are easy to change.

Telling users they should just do the script themselves is kind of missing the point here. Everything this tool does can also be done by users manually as well.

The entire point is convenience, and truth is a lot of people use flakes, and presumably would like the convenience of being able to generate a relatively suitable boilerplate, just the same as people using traditional nix architectures would.

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.

4 participants