How to clean your home folder (Warning about missing channels folder)

Hello,

I use the DeterminateSystems/nix-installer to install nix and when I run nix-shell I get this warning printed tens of times and flooding my terminal:

warning: Nix search path entry '/home/myuser/.nix-defexpr/channels' does not exist, ignoring

The folder seems to be a broken symlink and I am trying to figure out how to properly fix this. Here is the symlink

# Here is the link target which points to .local
❯ ls -al ~/.nix-defexpr/
total 8
drwxr-xr-x 1 1400601103 1400600513   42 Mar 16 10:29 .
drwxr-xr-x 1 1400601103 1400600513 2100 Mar 16 23:12 ..
lrwxrwxrwx 1 1400601103 1400600513   60 Mar 16 10:29 channels -> /home/myuser/.local/state/nix/profiles/channels
lrwxrwxrwx 1 1400601103 1400600513   44 Nov 25 15:38 channels_root -> /nix/var/nix/profiles/per-user/root/channels

# That is also a link to a directory in the same folder:
❯ ls -al /home/myuser/.local/state/nix/profiles/channels
lrwxrwxrwx 1 1400601103 1400600513 15 Mar 16 10:29 /home/myuser/.local/state/nix/profiles/channels -> channels-4-link

# Finally that points to a non-existent location
❯ ls -al /home/myuser/.local/state/nix/profiles/channels-4-link
lrwxrwxrwx 1 1400601103 1400600513 60 Mar 16 10:19 /home/myuser/.local/state/nix/profiles/channels-4-link -> /nix/store/9kqa0sa53c8fpjix5syjb2fllmk1m2xd-user-environment

# This does not exist
❯ ls -al /nix/store/9kqa0sa53c8fpjix5syjb2fllmk1m2xd-user-environment
ls: cannot access '/nix/store/9kqa0sa53c8fpjix5syjb2fllmk1m2xd-user-environment': No such file or directory

How can I fix this? I have some history on my system:

  • I am on an atomic distro (Bluefin, which is similar to Fedora Silverblue)
  • I tried installing nix in a toolbox as a single-user installation
    • Created an ubuntu podman/toolbox image
    • Inside that image installed nix in my user home (from the host, mounted by toolbox) but the /nix store was inside the image
    • Deleted the toolbox once I realized this is not a good idea
  • I deleted the toolbox and use the Determinate Systems installer to create a system installation

I wonder if this is some relic of the nix configuration inside my home that relies on the toolbox image. How can I clean my user home of all nix configuration?

Can I simply delete these:

  • ~/.nix-defexpr
  • .local/state/nix
  • …where else would there be leftover nix config?

Thanks

EDIT: This is what a search for nix yielded in my home:

./.local/share/nix
./.local/state/nix
./.nix-defexpr
./.nix-channels
./.cache/nix
./.nix-profile

I am inclined to simply delete everything as there is nothing I would care to preserve (I want to start fresh). Will update…

After deleting all of the above, everything works without the pesky warning appearing anymore.

Very basic question but perhaps a good resource on “how to clean your home folder from nix”

1 Like