Update and know the version of `nix-channel` (once again)

Some question about nix-channel:

  1. How to know which version you are on? I saw older post with this solution, is this really the way to go? Shouldn’t that be part of the nix-channel command?
$ sudo nix-channel --list
nixos https://nixos.org/channels/nixos-24.11
unstable https://nixos.org/channels/nixos-unstable

$ readlink /nix/var/nix/profiles/per-user/root/channels/unstable
/nix/store/l3mh15shxzh8nmqik45mxhx6q6igjzb8-unstable/unstable
  1. How to proceed then? l3mh15shxzh8nmqik45mxhx6q6igjzb8 part is considered to be the commit has, but i was not able to find something (e.g. with https://github.com/NixOS/nixpkgs/commit/l3mh15shxzh8nmqik45mxhx6q6igjzb8 or on https://channels.nix.gsc.io)

  2. How to update just one channel? The command below says it unpacked both channels… Is this just bad UX or did it really update both?

$ sudo nix-channel --update unstable
unpacking 2 channels...
  1. Why is this so hard? I thought some of the main advantage is to know exactly what is running on my system and can easily reproduce it… (don’t need an answer to that, just being frustrated that after over 2 years having nixos, I’m not able to do such simple things)
$ cat /nix/var/nix/profiles/per-user/root/channels/unstable/svn-revision
.765432.deadbeef0123

The bit after the second . is a Git commit prefix.

Unfortunately, you don’t. If you want more flexibility than what nix-channel offers, time to graduate to something like npins.

1 Like

Honestly, if you’ve been on NixOS for two years, just use npins in general. You won’t struggle with them, and it solves all badness of channels.

Just make sure you have no imports from <nixpkgs> or <nixos> in your config afterwards, and link your channels to your npins so that nix-shell & co work as expected.

@rhendric @TLATER Thanks for your answers. It just feels so weird to use a third-party tool for imho basic things. In my experience these, these tools keep popping up like mushrooms and will rot equally fast. So we have npins, niv (and even worse with nix tools for python, like mach-nix, python2nix, poetry2nix and the list goes one …).

It just defers the purpose of stability, reproducibility and long-term support I expect from my system, and I’m honestly thinking of turning my back to nixos because it often creates more problems than lot solve (at least for me, if it works for others that’s great).

I for sure know this feeling from back when I was new to the community. But reality is, npins was developed and is maintained by past or present leading contributors to the ecosystem, and while it‘s not under the Nix brand, it’s also not exactly third-party either.

The reasons — some social, some technical — for why we can’t just have everything lined up nicely, batteries included, are complicated and won’t be fixed tomorrow. NixOS is not one finished product and not one closed-loop organisation, but a collection of developing ideas with people coming and going, mostly volunteers.

I know this is not evident from looking at it superficially, and I know it’s annoying to first have to discuss these things instead of just reading them up in a central place. The reasons for this… are complicated. Believe me, we‘re slowly but steadily working on it. In the mean time, let’s enjoy the company of passionate people like @TLATER and @rhendric who are trying to make the world of computing a saner place.

I also strongly recommend using npins for managing remote sources, and it’s the endorsed tool in official documentation on nix.dev: Automatically managing remote sources with npins — nix.dev documentation

5 Likes

Would you mind elaborating on this? I currently have my pins on the nix search path, which seems different from what you are suggesting here and I’m wondering if I can improve what I am doing :slight_smile:

I agree that nix-channel is awful, I even disabled it on my systems.

However per the manual, nix-channel --update <arg> should only update the matching channel(s), not all. If it’s updating all channels that sounds like a bug, I’d say report it if you can reproduce it in a vm.

Yep, that’s pretty much what I suggest, this but pointing nixpkgs at your pinned nixpkgs instead.

1 Like