By neildaemond, an 'any-stack' hacking grasshopper.
Taking notes while tinkering with:
Nix Flake error: path '/nix/store/--/flake.nix' does not exist
I’ve noticed a ‘path _ does not exist’ quirk when copying the flake.nix
file from one project to another
I thought that I could replicate the nix-flake defined environment of one folder(project) by copying flake.nix
and .envrc
into a new folder. When I do that, I’m asked to run direnv allow
on the new folder, but then something weird happens; you’ll get an error like this:
direnv: loading ~/proj/project-name/.envrc
direnv: using flake .
error: path '/nix/store/0cc..nm8-source/flake.nix' does not exist
AI fails miserably when offering debugging help, telling me to rm -rf .direnv
then run direnv reload
.
Those commands don’t work because the nix flake or direnv looks for some folders whose names are derived from certain hash values in the .git folder
As it doesn’t work, AI will enter its death loop, where it tells you to do the same thing over and over.
It turns out, the solution is simple: git add flake.nix
If the flake-defined direnv has a .git/
folder, then the flake.nix
file needs to be staged/committed.
I delved into some other scenarios that didn’t end up being consistent, but in the end, the problem is caused when the flake.nix
file is not staged/committed. When the directory is not a git project, things work as expected.
#NixFlakes #Direnv