How should the nix cache be deleted? I am on MacOS Monterey. Is there a command for this or is it done by manually deleting directories?
Also is there is way to clean a particular store item for example I have an error on this one:
building '/nix/store/9z2bhjz6slfphlm4xbpkh9c0hzll46kh-source.drv'...
ErrorErrorxexecuting ' **/nix/store/067f780bk90ghn7yhz914d5fykmll7a4-bash-5.1-p16/bin/bash** ': **Bad file descriptor**
What if I want suspect this store item is corrupted and want to rebuild and have it download this again?
Well I tried deleting the cache files but I guess that was not a good idea:
deano@Ds-MacBook-Pro nix % nix-build
**error:** getting status of ' **/Users/deano/.cache/nix/default.nix** ': **No such file or directory**
deano@Ds-MacBook-Pro nix % sudo nix-build
**error:** getting status of ' **/Users/deano/.cache/nix/default.nix** ': **No such file or directory**
Can someone answer about correct way to clean the cache please?, and also if I need to reinstall or is there a way to reinit the cache and get the default.nix file back?
I grepped around in the source a bit and don’t see an obvious cleanup command.
I’m not sure if it’ll apply in your case, but you might want to try using --tarball-ttl 0 first to see if that skirts the issue without deleting anything.
It’s probably safe to delete in there, but I don’t have the confidence of someone who’s done it…
It depends on what you mean by “cache” and by “clean”. If you mean clean the /nix/store of unused packages, then yes, there is the nix-collect-garbage command. If you mean the evaluation cache, there is currently no command I am aware of, since it is still an experimental feature, but you can just manually delete ~/.cache/nix/eval-cache-v2 for now.
As far as deleting store paths, you can use nix-store --delete <store-path> to do so, as long as it is not still considered a “live” path, i.e. tied to a gc root.
well I did delete an individual item like that but what then will cause it to be updated? if I suspect an item in the cache is corrupt I want to delete it and then have it downloaded again. Is this possible?