0

I'd like to figure out the commit and date that a channel references.

For example how can determine that for the nixos2009 channel below?

sudo nix-channel --list
nixos https://nixos.org/channels/nixos-20.09
nixos-2003 https://nixos.org/channels/nixos-20.03
nixos2003 https://nixos.org/channels/nixos-20.03
nixos2009 https://nixos.org/channels/nixos-20.09
unstable https://nixos.org/channels/nixpkgs-unstable

I can see ls /nix/var/nix/profiles/per-user/root/channels-*/manifest.nix shows us the channel generations.. Which the latest channel generation has the following content:

cat /nix/var/nix/profiles/per-user/root/channels-61-link/manifest.nix | nixfmt
[
  {
    meta = { };
    name = "nixos-20.09.2538.0cfd08f4881";
    out = {
      outPath =
        "/nix/store/7s917s7ipvq3zmbx5g3kssldwc029r8r-nixos-20.09.2538.0cfd08f4881";
    };
    outPath =
      "/nix/store/7s917s7ipvq3zmbx5g3kssldwc029r8r-nixos-20.09.2538.0cfd08f4881";
    outputs = [ "out" ];
    system = "x86_64-linux";
    type = "derivation";
  }
  {
    meta = { };
    name = "nixos-2003-20.03.3324.929768261a3";
    out = {
      outPath =
        "/nix/store/zajz4gpq506g68w47pnl11k8mhz06jz0-nixos-2003-20.03.3324.929768261a3";
    };

Potentially I can get it from the store path above like /nix/store/zajz4gpq506g68w47pnl11k8mhz06jz0-nixos-2003-20.03.3324.929768261a3 - but I'm not sure (and not sure what that "path" is called either).

Seems like an answer for this is documented here: https://discourse.nixos.org/t/how-to-see-what-commit-is-my-channel-on/4818/6?u=chrissound though that is not a programmatic way (which is what I'm looking for).

0
  1. That manifest might be a nice way.

  2. Another (also in the linked forum) is

    readlink /nix/var/nix/profiles/per-user/root/channels-1-link
    
  3. And also, perhaps the easiest one:

    cat /nix/var/nix/profiles/per-user/root/channels/*/svn-revision
    
0

You can use nixos-version. Mine gives 20.03pre194293.2436c27541b (Markhor) where the last part is the commit hash. Not sure if it also works on stable, but it should.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.