A problem I keep running into with flakes is that by builds fail after running nix-collected-garbage -d
. Here’s an example:
nix build .#whatever
warning: Git tree '/home/emmanuel/projects/erosanix' is dirty
error (ignored): error: end of string reached
error: getting status of '/nix/store/cwihclkh4g6wghh67nq9lyswfjh650im-source': No such file or directory
(use '--show-trace' to show detailed location information)
The path matches the nixpkgs pinned in my flakes.lock:
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1642770210,
"narHash": "sha256-2kMgAMy3ThQP5UvHkV/z2zMkoml9bQhatEzCpLq5Iwc=",
"path": "/nix/store/cwihclkh4g6wghh67nq9lyswfjh650im-source",
"rev": "0bef0d60524fcdb2b609625e34d5c224e150c17a",
"type": "path"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}
I suspect this happens because I use “follows” in order to avoid using a bunch of different versions of Nixpkgs:
inputs.nixpkgs.url = "github:NixOS/nixpkgs/master";
inputs.agenix.url = "github:ryantm/agenix";
inputs.agenix.inputs.nixpkgs.follows = "nixpkgs";
inputs.erosanix.url = "github:emmanuelrosa/erosanix";
inputs.erosanix.inputs.nixpkgs.follows = "nixpkgs";
I can’t figure out how to get the Nixpkgs version I need (ex. /nix/store/cwihclkh4g6wghh67nq9lyswfjh650im-source) back in the Nix store. Using nixos-rebuild built --flake
works only after updating my inputs with nix flake update
. In other words, it won’t bring back the one that I need.
I don’t want to update Nixpkgs right now because as you can see, I use the master branch which is having issues at the moment.