# How to see what commit is my channel on?

**URL:** https://discourse.nixos.org/t/how-to-see-what-commit-is-my-channel-on/4818
**Category:** Help
**Created:** [November 16, 2019, 7:47am UTC](https://discourse.nixos.org/t/how-to-see-what-commit-is-my-channel-on/4818 "2019-11-16T07:47:58Z")
**Posts on this page:** 1
**Showing post:** 6

<div class="post-metadata">

### Author: ![toraritte](https://discourse.nixos.org/user_avatar/discourse.nixos.org/toraritte/32/6777_2.png) [@toraritte](https://discourse.nixos.org/u/toraritte)
#### Post date: [February 9, 2021, 5:39pm UTC](https://discourse.nixos.org/t/how-to-see-what-commit-is-my-channel-on/4818/6 "2021-02-09T17:39:51Z")

</div>

Just posting this here because I need things explained like to a 5 year old (and [SO threads](https://stackoverflow.com/questions/66124085/how-to-pin-an-import-nixpkgs-call-to-a-specific-commit) are prone to be closed/deleted/etc.):

> **Note** : **_Before trying any of these methods, make sure that you are issuing commands with the right user!_**  
> No harm done either way, but if you are on NixOS and [manage things declaratively](https://nixos.org/manual/nixos/stable/#sec-package-management) (as `root` when rebuilding the system) then you might get a different commit hash than what you need. (Especially if you ever issued `nix-channel --update` without `sudo`, which will set up a channel for **your** user profile as well.)
> 
> ### Method 0
> 
> According to the [NixOS wiki’s _Nix channels_ entry](https://nixos.wiki/wiki/Nix_Channels), “_a **channel** is a name for the latest “verified” git commits in [Nixpkgs](https://github.com/NixOS/nixpkgs)_”. That is, at any given time, a channel points to a specific commit in [the Nixpkgs git repository on Github](https://github.com/NixOS/nixpkgs); each Nix channel is actually a git branch in the repo:
> 
> ```
> $ nix-channel --list
> nixos https://nixos.org/channels/nixos-20.09
> ----- ----------- 
> (name) (branch-name)
> # |
> # V
> # https://github.com/NixOS/nixpkgs/tree/<branch-name>
> # i.e. https://github.com/NixOS/nixpkgs/tree/nixos-20.09
> 
> ```
> 
> So if you just executed `nix-channel --update` before `nix-shell`, and it works, just look up the last commit in the channel branch.
> 
> ### Method 1
> 
> [“_Chapter 12. Channels_” of the Nix manual](https://nixos.org/manual/nix/stable/#sec-channels) mentions that `nix-channel --update` “_makes the union of each channel’s Nix expressions available by default to `nix-env` operations (via the symlink `~/.nix-defexpr/channels`)_”.
> 
> To see where the `~/.nix-defexpr/channels` symlink points to, use `readlink -f` to follow the symlink chain and combine it with `ls` to get straight to the point:
> 
> ```
> $ ls -l $(readlink -f ~/.nix-defexpr/channels)
> total 6432
> dr-xr-xr-x 2 root root 4096 Jan 1 1970 ./
> drwxrwxr-t 8191 root nixbld 6569984 Feb 9 15:51 ../
> lrwxrwxrwx 1 root root 78 Jan 1 1970 nixos -> /nix/store/k737c631q19n54fhjmnf68frg5dar14w-nixos-20.09.3009.8e78c2cfbae/nixos/
> lrwxrwxrwx 1 root root 60 Jan 1 1970 manifest.nix -> /nix/store/a5wl1fri2sasnsb1i5zscni5h7kjg7d6-env-manifest.nix
> 
> ```
> 
> My channel’s name is `nixos`, and it points to
> 
> ```
> /nix/store/k7..4w-nixos-20.09.3009.8e78c2cfbae/nixos/
> -----------
> ^
> |
> channel-commit
> 
> ```
> 
> and the commit hash is right after the [MAJOR.MINOR.PATCH version number](https://semver.org/).
> 
> * * *
> 
> **Aside** : To construct the tarball URL for `fetchTarball` in the question, use the following template:
> 
> ```
> https://github.com/<user>/<repo>/archive/<full-or-abbr-commit-hash>.tar.gz
> 
> ```
> 
> For example:
> 
> ```
> https://github.com/NixOS/nixpkgs/archive/8e78c2cfbae.tar.gz
> 
> ```
> 
> Alternatively, click the green “Code” button, and copy the URL of the “Download ZIP” link (and change the `zip` extension to `tar.gz`).
> 
> * * *
> 
> **Fun fact** : if you did `nix-channel --update` before method 1, then URLs `https://github.com/NixOS/nixpkgs/tree/<branch-name>` and `https://github.com/NixOS/nixpkgs/tree/<channel-commit>` will point to the same place in the [Nixpkgs](https://github.com/NixOS/nixpkgs) repo.

---

_[View the full topic](https://discourse.nixos.org/t/how-to-see-what-commit-is-my-channel-on/4818)._
