Nix-channel revision/url -meta data


nix repl

:l <nixpkgs>

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 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": [

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

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

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

but I cannot find my channel

nix-channel --list  
cat `nix-instantiate --eval -E '<nixpkgs>'`/svn-revision

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 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 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.


nix-repl> :l
Added 12565 variables.

nix-repl> lib.version

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

nix-repl> lib.version

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`