Picking Specific version of a pkg

My pc nixos version is currently in 20.09, however master nixpkgs are still actively being updated because new pkgs get added and bugs fixed. I was wondering what’s the best practice to get the specific version of a pkg?

the following is what I have done for hugo

 self: super:
  let
     unstable-pkgs = import (builtins.fetchTarball {
     # 09.16.2020
     url = https://github.com/NixOS/nixpkgs/tarball/441a7da8080352881bb52f85e910d8855e83fc55;
  }) {config.allowUnfree = true;};
  in {
  # version : 0.74.3
  hugo = unstable-pkgs.hugo;
}

the issue here is I am not sure which commit will be stored to tarball, I have to do try and error to figure it out.

What is the best practice to do so?

There was a recent topic on this: Pin pkg at a certain version : chrome - chromedriver version fit

thanks! it works using buildins.fetchGit could avoid gussing and trying tarball version

Just note that fetchGit is much much slower than fetching an archive, which becomes significant if you have to rebuild often and much.

thanks ! do you know where to find the archive list? seem not all commit id is archived.

The archives on GitHub are most probably generated on demand and cached. It should be possible to just replace the commit ID, but maybe the service only fills the cache if you‘re authenticated. Try going through the web site and clicking on the Download dropdown for some commit you are viewing.