Hey guys, since a couple of days I have this strange problem with my NixOS installation:
I cannot run anything that evaluates flakes (that includes stuff like
nix flake check
nix flake build
nixos-rebuild --flake etc. etc…) when the target flake is on my local filesystem. When the same flake is a remote URL it works, see below for more info.
The error I get is always the same (hash changes of course from flake to flake):
error: getting status of ‘/nix/store/bhfv04vznm0hkyjjdidfbjlyid5bfkjv-source’: No such file or directory
I know that similar problems were already posted multiple times, here and on StackOverflow, and contain solutions, in particular this one: Nix flakes /nix/store/***-source no such file or directory.
Suggestions include running garbage collection followed by nix-store --repair-path … and/or nix-store --verify --check-paths --repair. Those suggestions do not help at all in my case, but I used them in the past to fix a similar problem and indeed they helped (concretely the nix-store-one).
So what’s different this time?
A - solutions do not work as mentioned, B - if I build the flake from remote location, it works without problems which confuse the hell out of me. So for example below does not work, fails with the mentioned error:
nixos-rebuild boot --flake .#m3800
While this works without problems (commits on both git repositories are the same):
nixos-rebuild boot --flake github:konradmalik/dotfiles#m3800
Flake that fails is my nix config repo on github, but I don’t think it’s relevant, since the error applies to all flakes I have locally.
Couple of (strange) facts about this whole situation:
- my flake.lock does not reference local paths like in the linked similar issue
- the git repo I have locally is of course the same as the remote one, it’s the same commit
- removing local repo and cloning again did not help
- cloning to another directory did not help
- this same flake works without problems on 3 other nixos systems I have, with the exception that this problematic one is a desktop (contains WM, graphical apps etc.) while others are server (just ssh access and terminal apps).
- this same flake works without problems on my MacBook pro via nix-darwin
- by “the same flake” I mean mostly the system/nix configuration, because as I said, nix flake check and the rest do not work on all flakes, not just my github repo
- when I build the flake from the remote path and then try to use the local one it will work (so it will properly create the ‘source’ folder in nix store), but as soon as I change anything, like commit some changes, it stops working until I again build it directly from the remote URL.
- as it turns out, some flakes fail even when provided with a remote URL. My company’s flake accessed over git+ssh fails with the exact same source-missing error whether it’s being run from local or from remote
- “in the heat of debugging” the suggestion to try
nix-store --verify-path /nix/store/bhfv04vznm0hkyjjdidfbjlyid5bfkjv-sourceworked once (it downloaded the source from my cachix url) but then the build threw another error about missing store path (‘files’ this time which is just my local package with my dotfiles), this one could not be fixed at all and since then, I’m not able to fix any such error with
- when I run
nix-collect-garbage -dafter trying to build the flake from local path, it will remove the lock file for that same source folder that it says is missing (that’s reproducible):
sudo nix-collect-garbage -d removing old generations of profile /nix/var/nix/profiles/per-user/root/channels removing old generations of profile /nix/var/nix/profiles/per-user/konrad/home-manager removing old generations of profile /nix/var/nix/profiles/system finding garbage collector roots... deleting garbage... deleting '/nix/store/bhfv04vznm0hkyjjdidfbjlyid5bfkjv-source.lock' deleting unused links... note: currently hard linking saves 2939.27 MiB 1 store paths deleted, 0.00 MiB freed
- as mentioned,
nix-store --verify --check-paths --repairdoes not fix anything, nor it reports any errors:
reading the Nix store... checking path existence... checking link hashes... checking store hashes...
Any ideas? I’m extremely confused.