Nix provides some builtins to fetch source code. It seems that we could use those instead of the nixpkgs fetchers.
Does it make sense to replace nixpkgs fetchers with the Nix fetchers?
It also seems that the builtin fetchers are doing the right thing:
$ nix-store -r $(nix-instantiate '<nixpkgs>' -A fetchgit --argstr url "https://github.com/NixOS/nix" --argstr hash "sha256-MtVatZVsV+dtjdD4AC4bztrnDFas+WZYHzQMt41FwzU=" --argstr rev "refs/tags/2.13.2")
/nix/store/clcvzin5nbaw8df7p3fqxicqsv135bwx-nix
$ nix-store -r $(nix-instantiate '<nixpkgs>' -A fetchgit --argstr url "https://github.com/NixOS/nix" --argstr hash "sha256-MtVatZVsV+dtjdD4AC4bztrnDFas+WZYHzQMt41FwzU=" --argstr rev "4935cf4d9b74405c753942197c9f328075793502")
/nix/store/kvjczzxhy5xvihyz301cwsamss51r56j-nix-4935cf4
$ nix-store -r $(nix-instantiate '<nixpkgs>' -A fetchzip --argstr url "https://github.com/NixOS/nix/archive/refs/tags/2.13.2.tar.gz" --argstr hash "sha256-MtVatZVsV+dtjdD4AC4bztrnDFas+WZYHzQMt41FwzU=")
/nix/store/7ncnkh5irwaii8gv028bb0cylb5y57x5-source
vs
$ nix eval --expr '(builtins.fetchGit { url= "https://github.com/NixOS/nix"; ref="refs/tags/2.13.2"; allRefs=true; narHash="sha256-MtVatZVsV+dtjdD4AC4bztrnDFas+WZYHzQMt41FwzU=";}).outPath'
/nix/store/7ncnkh5irwaii8gv028bb0cylb5y57x5-source
$ nix eval --expr '(builtins.fetchGit { url= "https://github.com/NixOS/nix"; rev = "4935cf4d9b74405c753942197c9f328075793502"; allRefs=true; narHash="sha256-MtVatZVsV+dtjdD4AC4bztrnDFas+WZYHzQMt41FwzU=";}).outPath'
/nix/store/7ncnkh5irwaii8gv028bb0cylb5y57x5-source
$ nix eval --expr '(builtins.fetchTarball {url="https://github.com/NixOS/nix/archive/refs/tags/2.13.2.tar.gz"; sha256="sha256-MtVatZVsV+dtjdD4AC4bztrnDFas+WZYHzQMt41FwzU=";})'
/nix/store/7ncnkh5irwaii8gv028bb0cylb5y57x5-source
The hash is always the same. We get 3 different store paths with the nixpkgs fetchers, but with the builtin fetchers we get always the same store path.