What causes the folder .nix-defexpr to be created in my home directory?

I looked up “.nix-defexpr” but I still don’t know what exactly that folder is for and why it needs to be in my home directory, my configuration is a flake, I use home manager, and I occasionally use nix-shell -p to try out apps. It has two folders: channels and channels_root, both containing a file manifest.nix which each just contain empty brackets: [ ].

It is part of nix (the “runtime”). It is where nix-channel would put its stuff. Or well, its a couple of symlinks to where nix-channel puts its stuff.

I am not aware of a way to get rid of it permanently other than completely disabling channels and then manually deleting all the leftovers from not having installed the system with disabled channels.

If I’m using and am comfortable with flakes, would there be any downsides to disabling channels? nix.channel.enable = false;

Unless you ever actually used nix-channel or installed with “copy channels”, then you won’t even have any “active” channel anyway.

Nix-path will still work.

Though I really have no clue, what leftovers there might be beyond ~/.nix-defexpr per user.

Oneechan69 discourse@discourse.nixos.org writes:

If I’m using and am comfortable with flakes, would there be any downsides to disabling channels? nix.channel.enable = false;

I have nix.channel.enable = false; for years, do not find any downsides.

2 Likes