/bio/skills/blog/math

Cleaning Nix Store from Devbox

Devbox is a pretty great interface for Nix. Natch, there re edge cases where devbox commands alone won't do. Recently, one of my python virtual environments in devbox kept having dependency problems. Although my requirements.txt had: docutils < 0.22, >= 0.20, I was still getting an old docutils 0.19 from my nix-store.

Devbox's documentation recommends the following command to clean up the Nix store:

devbox run -- nix store gc --verbose --extra-experimental-features nix-command

Note: all devbox commands must be run within a directory that has a devbox.json file. That is pick any directory in which you've already run devbox init.

However upon running

ls /nix/store | grep python3.9

I noticed the files were still there.

By default, nix keeps derivations so if a file in nix store still has a deriver, then it won't be garbage collected.

Running

devbox shell
# Then within the devbox shell:

nix-store --query --roots /nix/store/[path to python3.9]

This will output which of your devbox profile is using the package you want to get rid of. You can then go to that directory and delete said devbox profile.

2025 Stefano De Vuono