-
-
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
flakes: nix shell (and similar) fails, if flakes.nix inside a git-repo ist no yet added to the repo (error: getting status of '/nix/store/.../flake.nix': No such file or directory) #6642
Comments
This is the expected behavior AFAIK |
Summary: I'm not aware of a simple and easy solution to this UX annoyance that does not lead to more UX problems elsewhere. This is intended. While making this new behavior default would simplify a few situations, it will also make others more complicated. As an analogy to another technology that purports to provide reproducible source code trees (git) that does not provide a similar default behavior:
Perhaps the error message should be better, or there should be an easier way than |
Honestly the fact that flakes don't automatically add files is a feature, and for me it's one of the biggest draws because of its interaction with the eval cache. Sure sometimes I forget to add a file, but I almost always forget to |
I can understand, that this is by design and intended. I can even live with that decision. Regarding your next statement...
I am absolutely for that. I spent about two hours debugging this and I am and will not be the last one falling for that. The error message should be way more clearer for a better UX.
or something similar. |
Maybe (or certainly) I do not understand the full nix architecture in detail yet. |
I have the very same issue. My use case is this https://nixos.wiki/wiki/Flakes#Super_fast_nix-shell |
Ignoring I think you misunderstood my comment about how legacy UI commands would cause spurious rebuilds because unimportant files were added to the working dir. The common workaround was various source filters, notable Skipping these steps would cause Nix to rebuild projects needlessly, often to such a degree that it was easier for Nix files to be maintained externally. The new UI'S |
There is a pending PR which has a better message. What do you think about this? Lines 756 to 759 in 5f13402
|
This is a welcome solution for me! |
I've also lost several hours to this issue. Since it wasn't completely non-trivial to find, the PR that contains this change is #6530. That PR is also still a draft, so I'd prefer this to stay open until it's merged. |
This situation might be improved by making the nix CLI default to The usecase of adding a local |
That error message is indeed terrible UX, it provides no clue as to what's going on. |
Now this I actually agree with. For clarity though you should add |
in many situations that would also lead to copying lots of data into the nix store, which i would find to be a regression. people would have to readjust their habits to explicitly state since in the case of a dirty git tree users already get a warning, i suggest to also print a warning if |
It would only cause that in situations where currently it fails completely. When Moving from non-functionality to poor performance doesn't seem like a regression to me. |
ah, i interpreted your suggestion as changing the default unconditionally. but you meant it to be dependent on the |
Yes, that's what I meant. Indeed, it might be better to just pretend |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/doing-the-zero-to-nix-and-get-a-random-error/27692/8 |
2 years since the issue creation and we still cannot run nix develop when the flake.* files are in gitignore? This is my company's app and do not want to commit these flake files which are not related to the project and which are only used by me. Just let me do what I want instead of imposing me this decision... |
@jerlam06 have you tried |
The problem is that there isn't really a good solution here. If nix copies non-git files generally, then you end up with all kinds of detritus and intermediate files copied into the nix store, and then those intermediate files often mess up build processes because the timestamp data is gone. If you build only from the latest actual commit then it's too annoying to quickly test out a change to a flake. The compromise we've landed on is to use the dirty copies of any files tracked by git, but ignore other files. It's not perfect, but it's quite hard to come up with a change to it that wouldn't cost too much in terms of other unintuitive results. I'd love to see a nice solution to the usecase of adding a local flake.nix to a repo that doesn't have one upstream, but any such solution needs be considered in terms of all the effects it would have, not just that it solves that one issue. |
I don't think we should be forced to overload |
I hit the same issue and was very confused by this, Fixing the error message as per the above would have really helped me and would be a very welcome change. This is an issue that should be well documented in flakes documentation. But this is the first time I have seen this behavior documented. |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/problem-running-nix-develop/52249/3 |
this seems to have been fixed in #9398 but sadly isnt in the nix that ships with 24.05 :/ |
This looks like a regression caused by this PR: kolloch@598deb2 Since then the whole flake system also was under heavy development and refactoring. |
If a flakes.nix file is copied to a repository (empty or with content), then without adding it yet to the reposiroty, envoking
nix shell
and other flake related commands will fail with an error likerather than falling back to just use the locally available flake.nix (should be the default IMH).
Steps To Reproduce
git init test && cd test
nix shell
Expected behavior
A nix shell should be opened using the locally present but not yet added or commited
flakes.nix
.nix-env --version
outputnix-env (Nix) 2.8.1
Additional context
The flake.nix file, that I used
The text was updated successfully, but these errors were encountered: