You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This issue may sound silly but it's actually not clear to me what language they are written in.
The syntax and file ending both look like Nix but the manual doesn't apply most of the time.
The manual makes it seem like this should work:
error: expected a function but got a thunk at /nix/store/lm4pyqnkbiwvp2kxjd64nqb2xkdxmbfx-source/flake.nix:4:3
So what language are flake.nix files written in (is there any specification or documentation) and why is that language not Nix?
Reacted by Woynert, Volker Schukai, Rayane Nakib (ريّان نقيب), Léana, Raul Rodrigues de Oliveira, Jonathan Lee Komar, Jeff Huffman, Fenhl, Suraj, Jean Sidharta and 6 more
Reacted by AleXoundOS, tgunn, piegames, Janik, SandaruKasa, ryan4yin | 二花, ccornix, Sumire (菫), Magnus Groß, Ryan Brink and 11 more
Reacted by Attila Gulyas, Silvan Mosberger, Jairo Llopis, 0x241F31, Scott Olson, Manuel, dzmitry-lahoda, Niklas Gruhn, Dennis Gosnell, bhankas and 21 more
Reacted by ajs124, Josef Kemetmüller, remexre, Martin Weinelt, éclairevoyant, Yueh-Shun Li, soopyc, Juozas Norkus, ADoyle, dzmitry-lahoda and 23 more
It's a subset of Nix that doesn't allow computation in the flake metadata attributes. So e.g. outputs cannot be a function application like import ./outputs.nix, it must be a function directly outputs = { bla }: .... This is to prevent arbitrarily complex, possibly non-terminating computations while querying flake metadata.
This should be documented in the flake manpage.
Reacted by Manuel, Noon van der Silk, AleXoundOS, dzmitry-lahoda, ADoyle, Ryan J.P. Casalino, SamLukeYes, Lord-Valen, kiara, Aleksana and 14 more
I ran into this and was quite surprised and confused for about half an hour. I used let ... in ... at the top of my flake.nix and the resulting error message, "error: file '/nix/store/91d71n4sxkxnby3c3pbc8is4xm7a70r9-source/flake.nix' must be an attribute set" had me scratching my head (builtins.typeOf said it evaluated to an attribute set) and looking all over for someplace I had put some non-set type into a set position.
I didn't believe the error message was worded accurately and precisely because I am used to Nix error messages that tell me one type was expected in place of another with little or no further location information and I thought this was one of those cases.
An error message something like "file '...' must be written using the limited flake expression language" might have helped me discover my mistake more quickly.
Also, none of the docs I read on my way to learning about flakes said anything about this limited expression language so apart from tripping over this error I'm not sure how I would have learned about this.
Reacted by Bjørn Forsman, Skyler Grey, Ivan Kozik, ruro, Ben Mellor, éclairevoyant, 0x241F31, Scott Olson, chris montgomery, Dennis Gosnell and 50 more
Reacted by Attila Gulyas, Manuel Bärenz, Scott Olson, Grégoire Geis, Solène Rapenne, chris montgomery, AⱯ, dzmitry-lahoda, Suraj, Towry Wang and 8 more
could be awesome if there would be turing decidable(always halt) security attack protected(like infinite reference circular import parsing) nix which allows to be flake input limited flake expression language and that to be documented as flake input.
I don't really know if NixOS/rfcs#193 could be considered as a "solution" to the fact that flake.nix is not a nix file but rather a subset of nix with a specific schema file
It can be a solution if it becomes the only standard to write flakes in, since they wouldn't mislead into thinking flakes are full nix files to begin with. (which doesn't mean NixOS/rfcs#193 is desirable either)
It seems like bikeshedding, but xkcd 927 is basically what I'm fearing :
Working towards a removal of flake.nix is one way to settle the question, but yeah, only in a literal interpretation of the question posed, and I do think it's only a compelling vision when combined with NixOS/rfcs#194
I feel like this RFC should not just assume that the currently enforced status-quo limitation of "Flake input metadata can't contain arbitrarily complex, possibly non-terminating computations" must be kept as is, without justification. (...)
For example, do we know if this restriction is actually useful / needed? I think, I read somewhere that FlakeHub is relying on the fact that flake metadata can be computed statically-ish (I've never used FlakeHub, so I am not sure if this is actually the case). Are there any more examples where this property is actually useful?
If FlakeHub is the only (or one of the few) users of this restriction / guarantee, then maybe it should be implemented as a simple evaluation "depth" limiter on the side of FlakeHub, instead of in Flakes themselves?
Or maybe it's enough to have a simple way to opt-out of this restriction? Something like
{dynamic=true;inputs={# Arbitrary nix expressions are now allowed inside inputs,# because `dynamic` was set to true. This flake might not have# full functionality on services like FlakeHub, but this is fine.};}
Honestly, the more time I spend thinking about this, the less I like the idea that forcing static metadata is the correct solution. Restricting inputs to be static metadata is only one possible solution and it feels really weird that everyone just assumes it to be a non-negotiable requirement.
As I've mentioned previously, here are some alternative options off the top of my head (roughly in order of personal preference, from best to worst):
Use "full" nix, but have an evaluation depth / complexity limit (enforce it only where it's actually needed, ie on FlakeHub or when loading a flake from an untrusted source or something).
Allow "full" nix, but also evaluate a static version of the metadata and save it in flake.lock (warn/error if static metadata doesn't match the locally evaluated results). Bonus points: you can also precompute and save some static information about the available outputs (which could be useful for searching / indexing purposes).
Use "static" subset of nix by default, but have a way to opt-out (for users that don't care about FlakeHub, etc).
Accept either flake.nix or flake.toml. Allow "full" nix inside flake.nix. That way, users that care about FlakeHub/etc will use flake.toml (or only the static subset of flake.nix), while everyone else can write arbitrary expressions in flake.nix.
P.S. I already asked this before, but does anyone have any concrete examples where this static metadata requirement is actually needed other than on FlakeHub?
Reacted by Paul Grandperrin, StepBroBD, Ltrlg, thou-vow and Ludovic Fernandez
Arguably it's more controlled than the alternative, which is that users have to cobble together input modifications using scripts that perform text replacements in flake.nix, or things along those lines.
This is a strong argument;
People really wanting to compute their flakes inputs are just doing it regardless, in an unsafer way.
I'm not convinced that Flakes users need to be patronized in this way, or that IFD is particularly problematic here.
Arguably it's more controlled than the alternative, which is that users have to cobble together input modifications using scripts that perform text replacements in flake.nix, or things along those lines.
I am now completely convinced that nix should indeed allow non-trivial expressions in flakes (#15132);
To which extends is the question, and the current extends is unsatisfactory
I am also convinced that if #15132 was to be rejected, then NixOS/rfcs#193 (or another non-turing configuration language) AND deprecating flake.nix would be the only legitimate alternative to the concept of nix flakes;
Either flakes inputs are defined in a non-turing configuration language, either they are defined in Nix
The current state of flake being a loosely defined subset of nix is objectively wrong because of this indecision
I'm a user of flake-file because it allows me to declare inputs in different files. If flake inputs could be evaluated dynamically that would obviate the need to run a command that generates the flake.nix and that would make the workflow nicer and probably make flake-file obsolete, in favor of some built-in flake-parts support for declaring flake inputs.
Having said that, I would support a path similar to Lix, where flake features are frozen until the flakes are well defined and stable or whatever else ends up being their fate.
While this is offtopic, it's a short point and might serve @vaxerski and those who read his comment on the proliferation and handling of transitive inputs.
If a flake input can be consumed not via its flake outputs but instead by importing a nix file by path from it or perhaps by using it as a source, then its transitive inputs can be avoided by setting flake = false; (to be clear, the attr path is inputs.<name>.flake). This opts out of evaluating the inputs flake.nix and flake.lock. I do this whenever possible.
Activity
edolstra commentedon Jun 25, 2021
It's a subset of Nix that doesn't allow computation in the flake metadata attributes. So e.g.
outputscannot be a function application likeimport ./outputs.nix, it must be a function directlyoutputs = { bla }: .... This is to prevent arbitrarily complex, possibly non-terminating computations while querying flake metadata.This should be documented in the flake manpage.
stale commentedon Jan 3, 2022
I marked this as stale due to inactivity. → More info
dasJ commentedon May 19, 2022
Will care about this when the feature gets remotely usable for my use case so please leave this open
exarkun commentedon May 30, 2022
I ran into this and was quite surprised and confused for about half an hour. I used
let ... in ...at the top of my flake.nix and the resulting error message, "error: file '/nix/store/91d71n4sxkxnby3c3pbc8is4xm7a70r9-source/flake.nix' must be an attribute set" had me scratching my head (builtins.typeOfsaid it evaluated to an attribute set) and looking all over for someplace I had put some non-set type into a set position.I didn't believe the error message was worded accurately and precisely because I am used to Nix error messages that tell me one type was expected in place of another with little or no further location information and I thought this was one of those cases.
An error message something like "file '...' must be written using the limited flake expression language" might have helped me discover my mistake more quickly.
Also, none of the docs I read on my way to learning about flakes said anything about this limited expression language so apart from tripping over this error I'm not sure how I would have learned about this.
libexpr: improve triviality check error message
nix/flake.md: note that flakes do not evaluate metadata
nix/flake.md: flakes do not evaluate metadata outside of `outputs`
nix/flake.md: flakes do not evaluate metadata outside of `outputs`
nixos-discourse commentedon May 30, 2023
This issue has been mentioned on NixOS Discourse. There might be relevant details there:
https://discourse.nixos.org/t/can-i-use-flakes-within-a-git-repo-without-committing-flake-nix/18196/33
nixos-discourse commentedon Sep 7, 2023
This issue has been mentioned on NixOS Discourse. There might be relevant details there:
https://discourse.nixos.org/t/experimental-does-not-mean-unstable-detsyss-perspective-on-nix-flakes/32703/2
dzmitry-lahoda commentedon Nov 12, 2023
could be awesome if there would be turing decidable(always halt) security attack protected(like infinite reference circular import parsing) nix which allows to be flake input
limited flake expression languageand that to be documented as flake input.nixos-discourse commentedon Nov 14, 2023
This issue has been mentioned on NixOS Discourse. There might be relevant details there:
https://discourse.nixos.org/t/flakes-and-pollution-of-downstream-projects/35411/8
infinisil commentedon Nov 14, 2023
This issue has a better title and description, but it's a effectively a duplicate of #3966, which has a bunch more discussion.
18 remaining items
roberth commentedon Dec 7, 2025
I've opened NixOS/rfcs#193 to explore a solution to this.
Malix-Labs commentedon Apr 8, 2026
I don't really know if NixOS/rfcs#193 could be considered as a "solution" to the fact that
flake.nixis not a nix file but rather a subset of nix with a specific schema fileIt can be a solution if it becomes the only standard to write flakes in, since they wouldn't mislead into thinking flakes are full nix files to begin with. (which doesn't mean NixOS/rfcs#193 is desirable either)
It seems like bikeshedding, but xkcd 927 is basically what I'm fearing :
roberth commentedon Apr 8, 2026
Working towards a removal of flake.nix is one way to settle the question, but yeah, only in a literal interpretation of the question posed, and I do think it's only a compelling vision when combined with NixOS/rfcs#194
ruro commentedon Apr 8, 2026
Cross-posting from my comment on the RFC:
Honestly, the more time I spend thinking about this, the less I like the idea that forcing static metadata is the correct solution. Restricting
inputsto be static metadata is only one possible solution and it feels really weird that everyone just assumes it to be a non-negotiable requirement.As I've mentioned previously, here are some alternative options off the top of my head (roughly in order of personal preference, from best to worst):
Use "full" nix, but have an evaluation depth / complexity limit (enforce it only where it's actually needed, ie on FlakeHub or when loading a flake from an untrusted source or something).
Allow "full" nix, but also evaluate a static version of the metadata and save it in
flake.lock(warn/error if static metadata doesn't match the locally evaluated results). Bonus points: you can also precompute and save some static information about the available outputs (which could be useful for searching / indexing purposes).Use "static" subset of nix by default, but have a way to opt-out (for users that don't care about FlakeHub, etc).
Accept either
flake.nixorflake.toml. Allow "full" nix insideflake.nix. That way, users that care about FlakeHub/etc will useflake.toml(or only the static subset offlake.nix), while everyone else can write arbitrary expressions inflake.nix.P.S. I already asked this before, but does anyone have any concrete examples where this static metadata requirement is actually needed other than on FlakeHub?
Malix-Labs commentedon Apr 8, 2026
Also see #15132, which is related about the last comment
#15132 (comment) from @Malix-Labs :
Malix-Labs commentedon Apr 8, 2026
#4945 (comment) from @edolstra :
And also in https://nix.dev/manual/nix/latest/command-ref/new-cli/nix3-flake.html#flake-format and https://nix.dev/manual/nix/2.34/command-ref/new-cli/nix3-flake.html#flake-inputs
Currently, there is no clear mentions of the flake inputs limitations raised in this issue
Malix-Labs commentedon Jun 23, 2026
I just discovered https://github.com/denful/flake-file
@roberth is right in #15132 (comment) :
I am now completely convinced that nix should indeed allow non-trivial expressions in flakes (#15132);
To which extends is the question, and the current extends is unsatisfactory
I am also convinced that if #15132 was to be rejected, then NixOS/rfcs#193 (or another non-turing configuration language) AND deprecating
flake.nixwould be the only legitimate alternative to the concept of nix flakes;Either flakes inputs are defined in a non-turing configuration language, either they are defined in Nix
The current state of flake being a loosely defined subset of nix is objectively wrong because of this indecision
mightyiam commentedon Jun 23, 2026
I'm a user of flake-file because it allows me to declare inputs in different files. If flake inputs could be evaluated dynamically that would obviate the need to run a command that generates the
flake.nixand that would make the workflow nicer and probably make flake-file obsolete, in favor of some built-in flake-parts support for declaring flake inputs.Having said that, I would support a path similar to Lix, where flake features are frozen until the flakes are well defined and stable or whatever else ends up being their fate.
vaxerski commentedon Jul 20, 2026
I have to use flake-file to avoid the absolute ugliness of flake.nix for my needs.
I develop hyprland, and I need to be dogfooding my own software on the absolute latest revs.
Now, problem is, when you have like 10 apps and 10 libraries, it turns into this fiesta of:
which is a) an eyesore and b) a maintenance nightmare, because if any dep gets added, I need to manually keep track of it and add it.
With flake-file, I can actually generate those automatically.
The basic flake.nix seems awfully restricted.
Malix-Labs commentedon Jul 20, 2026
See #15132 (comment) from @roberth, which is an instance of what Vax is doing
mightyiam commentedon Jul 21, 2026
While this is offtopic, it's a short point and might serve @vaxerski and those who read his comment on the proliferation and handling of transitive inputs.
If a flake input can be consumed not via its flake outputs but instead by importing a nix file by path from it or perhaps by using it as a source, then its transitive inputs can be avoided by setting
flake = false;(to be clear, the attr path isinputs.<name>.flake). This opts out of evaluating the inputsflake.nixandflake.lock. I do this whenever possible.libflake: allow arbitrary expr in flake.nix
libflake: allow arbitrary expr in flake.nix
libflake: allow arbitrary expr in flake.nix
libflake: allow arbitrary expr in flake.nix