Repository navigation
Description
Is your feature request related to a problem? Please describe.
When a flake input has unneeded dependencies, it might be desirable to ensure that they won’t be downloaded or accessed. (e.g. when nix flake archive is used).
Describe the solution you'd like
I’d like to have the possibility to do something like
inputs.foo = { url = "..."; inputs.bar = null; }
This would ideally clearly fail with an error message whenever that flake input would be accessed during evaluation.
Describe alternatives you've considered
-
I considered uploading an
emptyflake on github with aflake.nixwhich contains{ outputs = _:{}; }.
Then I could doinputs.bar.url = github:user/empty;this has the downside of unnecessary network requests, especially because this might be needed in moments when there is no network access. -
A flake like that could even be added to the registry, so that one could do
inputs.bar.url = "empty";but that has the same downsides. -
I have tried
inputs.foo.inputs.bar = { url = "file:/dev/null"; flake = false; }. This works to add a dummy input to a flake, i.e.{ inputs.foo = { url = "file:/dev/null; flake = false; }. (I don’t know why one would ever do that.) However, when overriding a dependency this way if the dependency (in this casefoo) has not setflake = falseforbarthen it will still try to access theflake.nixof/dev/nulland thus throw an error. -
An alternative solution which requires a change in nix might be
inputs.bar.url = "empty";butemptyis considered magic and resolves to the flake suggested in 1. without network access. -
An inline flake input would also help here, e.g.:
inputs.bar = { type = "inline"; value = { outputs = _:{};}but it’s a rather crazy idea.
Activity
maralorn commentedon Feb 11, 2023
To clarify: I am not a big fan of any of those solutions I just would like to control the dependency closure of my flake somehow.
NobbZ commentedon Feb 12, 2023
In my blog I had troubles with a nar error for an unneded input. And as it wasn't actually needed I let it follow yet another flake input (in this case
nixpkgs), though someone else said making it follow""should work as well, which I just tried, and anix flake prefetchand anix buildstill seem to complete succesfully.https://github.com/NobbZ/nobbz-dev-astro/blob/main/flake.nix#L6-L7
maralorn commentedon Feb 13, 2023
Yes,
inputs.foo.inputs.bar.follows = ""is my current workaround. It works, but error messages from that can be very gnarly and it might produce very weird bugs if no error occurs.roberth commentedon Feb 13, 2023
This means to follow the local flake aka
self.When the interaction between your dependency and its dependency changes, this could lead to some weird errors. A null flake could throw a clear error instead:
flake input 'foo.bar.baz' was set to 'null' by 'foo', but it appears to be needed nonetheless.or something.maralorn commentedon Feb 13, 2023
Yeah, exactly. That’s why I opened this issue. Edit: (Ah, you weren’t quoting me. Then my response is not that necessary.)
NobbZ commentedon Feb 14, 2023
Interesting, I wasn't aware of these semantics and always assumed this was "the empty flake" already.
Indeed an explicit null/empty flake would make it much nicer and nix understanding the intend would improve the possibility of error reporting a lot!
Thank you for explaining the differences.
nixos-discourse commentedon Feb 20, 2023
This issue has been mentioned on NixOS Discourse. There might be relevant details there:
https://discourse.nixos.org/t/2023-02-17-nix-team-meeting-minutes-33/25624/1
flake: remove redundant transitive dependencies (#1986)
valpackett commentedon Feb 7, 2026
I have a different use case for an actual null input. I want a non-flake input (source code) to be null by default…
…in order to be able to override sources from the command line like
nix develop --override-input thing-src ../thing-srcwithout incurring the overhead of the source being an input to the flake when not overriding. I.e. when not overriding, I want to keep reusing the existing cache for afetch…derivation that's used as the source, which flake inputs can't reuse.concepts/flakes: remove unimplemented null input (#1239)
syborg64 commentedon Nov 12, 2026
Nix store have a similar concept of a dummy store
Is is a valid but empty store.
One clean way to support these sorts of usecases would be to have a (first-party) dummy flake which is a valid but empty flake.
The same dummy url used by stores
dummy://is already syntactically compatiblesyborg64 commentedon Nov 12, 2026
For users wanting a similar functionality before proper support, we can achieve this with
file:///dev/nullas a non-flake.Evaluating it returns an empty source.
some boilerplate can evaluate it as a flake by importing the contained
flake.nix(when pointed to a real flake)As long as it's not evaluated, it won't fail. More boilerplate can be added to let it evaluate to an empty flake (when pointed to /dev/null)