Nix-channel --list gives empty prompt back

As far as I am aware, is the command nix-channel --list supposed to give me at least the default channel back.

I never changed anything about my channels

Why is it empty?

Assuming you’re on NixOS, you will probably get something from:

sudo nix-channel --list

Every user on your system has their own set of channels. They do not need to point to the same version of nixpkgs, or even point at nixpkgs at all.

Channels are kind of like a local clone of a git repository, nix just reads some nix code in them to evaluate and figure out package builds from there. The various nix-channel commands are a bit like using git clone and git pull.

That’s why they are so flexible; you can install and update lots of different versions of lots of things at the same time - naturally, this can cause lots of confusion and complexity, too, especially because they are a little hidden, and rarely explained very well IMO.

When you install things with nixos-rebuild, the nixos channel of the root user will be used as the source for your packages.

When installing under any other conditions, the nixos or nixpkgs channel of the respective user, or the root user will be used (assuming it is not overriden by the NIX_PATH variable or the -I cli flag).

Your user channels appear to be empty, but your root user’s channels are likely not. So you’re just using the root user’s channels for all commands currently (I would recommend you continue doing this, personally, and always use sudo nix-channel, for your own sanity’s sake).

Channels are a bit fragile, and very imperative. Your system is not really reproducible as long as you use them. They’re a bit of an artefact of the development history of nix - at the time, better abstractions were probably just still too different from traditional tools to be imagined or at least allow nix to become popular.

The nix community has since developed flakes and niv to get rid of them; Both are much less magic, and therefore harder to be confused about IMO - unfortunately neither has yet managed to become the default way to manage the “version” of your system.