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
{{ message }}
Repository navigation
Flakes: Not including untracked files is confusing for unaware users. #7107
As flakes become more and more common, so too is the issue that untracked files aren't included when your flake is copied to the nix store. Personally, I consider this behavior a good thing, as it prevents me from accidentally copying result symlinks or nixos.qcow2 images into the store unnecessarily. But in my experience assisting users on Matrix and Discourse, it's a common error to not track a necessary file with git. This manifests with users being very confused why their shiny new code seems to not exist at all.
I'm not sure what the answer is here. Again, I personally prefer the current behavior, but clearly it's a problem for people who are unaware of the cause. I figured there should be an open issue to at least discuss the matter.
Reacted by Noon van der Silk, Jørn Lode, Robert Timm, Domen Kožar, Catherine West, squalus, Tobias Bergkvist, MidAutumnMoon, zopsicle, ilian and 86 more
I'd honestly be happy/expect to see this pop up when running adding some verbosity to the commands; it's what I tried to do to debug the issue, and was left confused when additional v's didn't yield me any particularly relevant hints ....
With #6530, the problem of accidentally copying large untracked files should no longer exist.
I think it'd make sense to disable the unintuitive git integration then.
I'm all for integrating different tools with another but that should always be an optional feature. A build tool should not care about which VCS I'm using or what its state is; especially not by default. (Being able to fetch a build expression via git is a great feature though.)
Reacted by Gergő Gutyina, Amy, katelyn martin and Linden Krouse
I too was pretty surprised at the tight git integration, and it makes certain things impossible, like conditionally importing an untracked file that may or may not exists (i.e. poor mans secret management, or a way to let folks customize a nix shell in a large shared repo).
Reacted by Davids Paskevics, Gürkan, saucoide, fwcd, vi, Amy, Sylvain Colignon, Adrian Hesketh, Oishik Ganguly, inson1 and 5 more
Even being familiar with this behavior, I find it cumbersome/unintuitive, and it is one of my biggest barriers to moving from traditional nix over to flakes.
What if instead of using the git staging area, there was a .flakeignore, similar to .dockerignore/.gitignore? I think this would be a lot more intuitive to new users, and could provide similar benefits in a more flexible way.
It might also be a step towards decoupling nix flakes and git - such that companies that use alternatives to git for version control would actually be able to adopt flakes as well.
Reacted by Atemu, MidAutumnMoon, Yacine Hmito, zopsicle, Fumiaki Kinoshita, Hardy Jones, Tomodachi94, Jan Gazda, JR Smith, Davids Paskevics and 23 more
It is also extremely frustrating on nixos with direnv for development environments, where the project does not need or want the flake in version control. I have to remove the nix files from git, commit, and re-add them. The only reason for these flakes to exist is to set up my local dev env.
Reacted by Hardy Jones, Magnus Bergmark, Davids Paskevics, Mirsario, Mark Bestley, saucoide, Aankhen, lbonn, Ariel Richtman, Ameya Shenoy and 11 more
Could nix by default use path:. instead of git+file:. when flake.nix is untracked and/or gitignored? It would at least streamline the local-only flake.nix usecase.
Reacted by Atemu, Hardy Jones, Gergő Gutyina and Jeff Labonte
Being newish to nix and flakes I'm definitely in the user group of of 'unaware users'. One problem I run into is that I might want a .env in the development shell, but definitely don't want to track in git (it's in my .gitignore so I don't accidentally add, commit and push it).
I'm not sure what the best practice is for this with flakes, but my first guess of having an .env file in the directory with flake.nix appears to be wrong.
Reacted by Davids Paskevics and Agustín Covarrubias
I think the behaviour is right, but some breadcrumbs in the error message about it being potentially related to source control would be very much appreciated.
Reacted by ryanalta, Joe Harrison, Pete Murphy, Kayla Firestack, Jan Gazda, ShaddyDC, Eman Resu, Timur Buslov, Dominik Schwaiger and Frieder Schrempf
It would be great to have a warning or hint if the local file is untracked.
It is my second day of learning nix and this behaviour is quite confusing.
Because the problem with untracked files appears only inside the git repo which I have not initialized for small learning projects, then after progressing towards a more real project I kept getting the error No such file or directory and it took me some time to realize that it may be an untracked file.
Reacted by Noon van der Silk, Andrei, Mark Bestley, Aankhen, Ameya Shenoy, Hugh Mandalidis, Gergő Gutyina, Lucas Gager and Agustín Covarrubias
Another factor that exacerbated the confusion for me is that this behavior also aplloes wheb you are in an ignored subfolder of a repo with a root higher up the tree. I sync my dotfiles by making my $HOME a git repo, so when i went into my projects directory and attempted to create a flake with nix flake init, it failed to build with an extremely unhelpful "No such file or directory" error that provided zero indication what the actual problem was.
Reacted by Shahar "Dawn" Or, ryanalta, Ameya Shenoy and Max Wipfli
Just to point out. it is path:<flake-ref> not :path<flake-ref>, aside from that, it does fix the issue.
I just want to point out also that this STILL happens even if operating in a sub-directory which is explicitly ignored by .gitignore.
I think this is deeply unintuitive, and does more harm than good.
Why would you have files in an ignored directory, you ask ? For example, you may be generating these configuration files - and there might be good reasons for that.
Reacted by Amanda Graven, Max Wipfli, Amy, Balthild and Linden Krouse
A dozen workarounds have been mentioned upthread e.g. #7107 (comment) and #7107 (comment), can this not become a support thread asking the same questions repeatedly?
Reminder that you do not need to commit anything. git add -N is sufficient if you don't want to stage the changes yet.
edit: thumbs down notwithstanding, my statement is still correct.
Thank you for the git add -N tip.
To add to that, for not committing files by accident, I use git update-index --skip-worktree <your-file>. So, it won't even show up as modified when you go to commit.
And you can add it to your Nix dev shell if you want to make it automatic for all contributors.
Hope this helps someone to not commit private info to GitHub.
It seems like there is a related recent regression, though I haven't been able to bisect it to an exact nix commit yet.
Observed:
If your .git points to a different directory gitdir: /some/other/path, then nix behaves as if the repo was not updated even if changes are staged / committed. Adding --refresh to the nix command line fixes that.
Before the regression, it will correctly pick up all staged / committed changes even if the .git directory lives outside directory containing the flake.nix.
Activity
silky commentedon Sep 27, 2022
Thanks for making this issue :)
I'd honestly be happy/expect to see this pop up when running adding some verbosity to the commands; it's what I tried to do to debug the issue, and was left confused when additional
v'sdidn't yield me any particularly relevant hints ....Kha commentedon Sep 28, 2022
Relevant: #6858 (comment) and following comments
squalus commentedon Dec 27, 2022
For anyone else running into this, here's how to include untracked files:
nix build path:///path/to/myflake#mypackage.The entire flake directory gets copied to the Nix store in this case.
Atemu commentedon Jan 1, 2023
With #6530, the problem of accidentally copying large untracked files should no longer exist.
I think it'd make sense to disable the unintuitive git integration then.
I'm all for integrating different tools with another but that should always be an optional feature. A build tool should not care about which VCS I'm using or what its state is; especially not by default. (Being able to fetch a build expression via git is a great feature though.)
andrewhamon commentedon Jan 6, 2023
I too was pretty surprised at the tight git integration, and it makes certain things impossible, like conditionally importing an untracked file that may or may not exists (i.e. poor mans secret management, or a way to let folks customize a nix shell in a large shared repo).
silky commentedon Jan 6, 2023
Depending on your setup @andrewhamon you might be interested in something like this - https://github.com/hasura/graphql-engine/blob/master/.envrc#L59 - to source a local .envrc file.
bergkvist commentedon Jan 11, 2023
Even being familiar with this behavior, I find it cumbersome/unintuitive, and it is one of my biggest barriers to moving from traditional nix over to flakes.
What if instead of using the git staging area, there was a .flakeignore, similar to .dockerignore/.gitignore? I think this would be a lot more intuitive to new users, and could provide similar benefits in a more flexible way.
It might also be a step towards decoupling nix flakes and git - such that companies that use alternatives to git for version control would actually be able to adopt flakes as well.
outfoxxed commentedon Jan 21, 2023
It is also extremely frustrating on nixos with direnv for development environments, where the project does not need or want the flake in version control. I have to remove the nix files from git, commit, and re-add them. The only reason for these flakes to exist is to set up my local dev env.
tejing1 commentedon Jan 25, 2023
Could nix by default use
path:.instead ofgit+file:.whenflake.nixis untracked and/or gitignored? It would at least streamline the local-onlyflake.nixusecase.ryanalta commentedon Feb 1, 2023
Being newish to nix and flakes I'm definitely in the user group of of 'unaware users'. One problem I run into is that I might want a
.envin the development shell, but definitely don't want to track in git (it's in my.gitignoreso I don't accidentally add, commit and push it).I'm not sure what the best practice is for this with flakes, but my first guess of having an
.envfile in the directory withflake.nixappears to be wrong.mwotton commentedon Apr 28, 2023
I think the behaviour is right, but some breadcrumbs in the error message about it being potentially related to source control would be very much appreciated.
1oglop1 commentedon Sep 10, 2023
It would be great to have a warning or hint if the local file is untracked.
It is my second day of learning
nixand this behaviour is quite confusing.Because the problem with untracked files appears only inside the git repo which I have not initialized for small learning projects, then after progressing towards a more real project I kept getting the error
No such file or directoryand it took me some time to realize that it may be an untracked file.agraven commentedon Nov 29, 2023
Another factor that exacerbated the confusion for me is that this behavior also aplloes wheb you are in an ignored subfolder of a repo with a root higher up the tree. I sync my dotfiles by making my $HOME a git repo, so when i went into my projects directory and attempted to create a flake with
nix flake init, it failed to build with an extremely unhelpful "No such file or directory" error that provided zero indication what the actual problem was.nixos-discourse commentedon Jan 7, 2024
This issue has been mentioned on NixOS Discourse. There might be relevant details there:
https://discourse.nixos.org/t/weird-missing-nix-store-when-running-a-home-manager-rebuild/37898/2
9 remaining items
nixos-discourse commentedon Nov 3, 2024
This issue has been mentioned on NixOS Discourse. There might be relevant details there:
https://discourse.nixos.org/t/path-nix-store-does-not-exist/55413/4
jwdevantier commentedon Jan 14, 2025
Just to point out. it is
path:<flake-ref>not:path<flake-ref>, aside from that, it does fix the issue.I just want to point out also that this STILL happens even if operating in a sub-directory which is explicitly ignored by
.gitignore.I think this is deeply unintuitive, and does more harm than good.
Why would you have files in an ignored directory, you ask ? For example, you may be generating these configuration files - and there might be good reasons for that.
Ev357 commentedon Feb 8, 2025
I'm sure that there is a good reason for this behaviour, but maybe an option to disable this for quick testing?
eclairevoyant commentedon Feb 8, 2025
A dozen workarounds have been mentioned upthread e.g. #7107 (comment) and #7107 (comment), can this not become a support thread asking the same questions repeatedly?
brbsleepy commentedon May 30, 2025
hello, i just stepped on this rake.
redirected from the helpful people here:
https://discourse.nixos.org/t/path-nix-store-does-not-exist/55413/2
i'd love to see some mention of git tracking in the error message
sleroq commentedon Jun 4, 2025
Thank you for the git add -N tip.
To add to that, for not committing files by accident, I use
git update-index --skip-worktree <your-file>. So, it won't even show up as modified when you go to commit.And you can add it to your Nix dev shell if you want to make it automatic for all contributors.
Hope this helps someone to not commit private info to GitHub.
Fix Home Manager switch to include Git-ignored file `customization.nix`
non-bin commentedon Jul 7, 2025
Just spent half an hour debugging because of this, I'm a seasoned nix user and I just forgot. I don't think it would be hard to add a check like this:
It might involve making a list of untracked files during pre-build and keeping it around in case of an error. Maybe I'll take a look sometime
gauravjuvekar commentedon Jul 7, 2025
It seems like there is a related recent regression, though I haven't been able to bisect it to an exact nix commit yet.
Observed:
If your
.gitpoints to a different directorygitdir: /some/other/path, then nix behaves as if the repo was not updated even if changes are staged / committed. Adding--refreshto the nix command line fixes that.non-bin commentedon Jul 7, 2025
What was the behaviour before the regression?
gauravjuvekar commentedon Jul 10, 2025
Before the regression, it will correctly pick up all staged / committed changes even if the .git directory lives outside directory containing the
flake.nix.non-bin commentedon Jul 11, 2025
oh, that's not my issue :P
I just forget to stage new files
nixos-discourse commentedon Jul 28, 2025
This issue has been mentioned on NixOS Discourse. There might be relevant details there:
https://discourse.nixos.org/t/using-nonfree-fonts-in-flake-config-without-git-tracking-them/67303/1
nixos-discourse commentedon Sep 17, 2025
This issue has been mentioned on NixOS Discourse. There might be relevant details there:
https://discourse.nixos.org/t/why-does-nix-require-flake-files-in-the-root-of-git-folders/69481/1
nixos-discourse commentedon Nov 1, 2025
This issue has been mentioned on NixOS Discourse. There might be relevant details there:
https://discourse.nixos.org/t/nix-flake-path-does-not-exist-even-though-everything-is-tracked-in-git/71596/1