Nix-channel revision/url -meta data

Hello

in
nix repl

:l <nixpkgs>
 config

it is possible to inspect what inside the channel


What interests me are the meta data
like in
nix-shell -p nix-prefetch-git --run ' nix-prefetch-git https://github.com/nixos/nixpkgs-channels.git refs/heads/nixos-unstable '

{
“url”: “GitHub - NixOS/nixpkgs-channels: DEPRECATED! Use NixOS/nixpkgs repository instead.”,
“rev”: “84d74ae9c9cbed73274b8e4e00be14688ffc93fe”,
“date”: “2020-09-26T18:54:09-07:00”,
“sha256”: “0ww70kl08rpcsxb9xdx8m48vz41dpss4hh3vvsmswll35l158x0v”,
}


but from/for the current channel[s] of the OS

1 Like

You can try inspecting the derivation:

$ nix show-derivation $(nix-store --query --deriver $(nix-instantiate --eval --expr '<nixpkgs>'))
{ 
  "/nix/store/zvxv9sl4232w8irhpxd7b5hp6h2iljfd-nixos-19.09.2520.289466dd6a1.drv": {
    "inputSrcs": [
      "/nix/store/a6zdbsflqj152v16l8xds18yakckls2p-nix-2.1.1",
      "/nix/store/hg88w6nh54z2i8qa7zljxdvj2bkavw0x-nixexprs.tar.xz",
      "/nix/store/sfdmj74sfra43h215r3b9glp3q1l14hd-unpack-channel.sh"
    ],
...

thanks for your answer

  • is it possible to get the rev(ision) hash and date as well?

I notice there’s a svn-revision file in there that contains the git commit.

$ cat `nix-instantiate --eval -E '<nixpkgs>'`/svn-revision
.2520.289466dd6a1

289466dd6a1 is the nixpkgs commit hash.

I’m not sure about the date.

that is interesting.
But then how to match it with references from https://channels.nix.gsc.io/nixos-20.09/history-v2?

It appears to be there, I just haven’t updated my channel in a long time. The hash I found above (289466dd6a1) shows up here as 289466dd6a11c65a7de4a954d6ebf66c1ad07652 1592518222 1592908512

https://channels.nix.gsc.io/nixos-19.09/history-v2

but I cannot find my channel

nix-channel --list  
home-manager https://github.com/rycee/home-manager/archive/release-20.09.tar.gz
nixos https://nixos.org/channels/nixos-20.09
cat `nix-instantiate --eval -E '<nixpkgs>'`/svn-revision
beta992.7badbf18c45

is not listed.

nix-instantiate --eval -E '(import <nixpkgs> {}).lib.version'
(that was what i forgot :- )

1 Like

I’m not sure how history-v2 gets generated. Looking at https://channels.nix.gsc.io/nixos-20.09/ it seems to have a timestamp of 29-Sep-2020 which is before 7badbf18c45 was merged.

I didn’t know about lib.version, I’m going to start using that.

1 Like

if i wasn’t confused about channels before, I am now ;-).

I wonder why

nix-channel --list

doesn’t show
nixos https://nixos.org/channels/nixos-20.03 version:14.04.526.dbadfad

for mere uninitiated nix foo masters?

might be friendlier… but arn’t channels being currently nuked from orbit in favour of flakes?

There’s other use cases for channels, such as production systems where you want the underlying package set to update for you with security updates.

yep

nix-repl> :l
Added 12565 variables.

nix-repl> lib.version
"21.03.git.0932db581d2"

nix-repl> :l <nixpkgs>
Added 12274 variables.

nix-repl> lib.version
"20.09pre239318.c59ea8b8a0e"

for “doing a release”, the parameters are passed into the jobset so they are correct:

# pkgs/top-level/release.nix
{ nixpkgs ? { outPath = (import ../../lib).cleanSource ../..; revCount = 1234; shortRev = "abcdef"; revision = "0000000000000000000000000000000000000000"; }
1 Like

lib.version seems the way to get it, i presume this is the same thing nix-info -m shows?

nix-shell -p nix-info --run "nix-info -m"

 - system: `"x86_64-linux"`
 - host os: `Linux 5.4.66, NixOS, 20.03.3011.13a15f262a2 (Markhor)`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.3.6`
 - channels(root): `"nixos-20.03.3011.13a15f262a2"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`
2 Likes