nmattia / niv

Easy dependency management for Nix projects
https://github.com/nmattia/niv
MIT License
1.55k stars 77 forks source link

Use /refs/tags/<tag> to specify git tags to support the current and master version of Nix #266

Closed basvandijk closed 4 years ago

basvandijk commented 4 years ago

Nix master doesn't seem to support specifying git tags as refs anymore. For example the following works in the current 2.3.8 release of Nix:

$ nix repl
Welcome to Nix version 2.3.8. Type :? for help.
nix-repl> builtins.fetchGit { url = "..."; ref = "some-tag"; rev = "..."; }
{ outPath = "/nix/store/...-source"; rev = "..."; revCount = ...; shortRev = "..."; }

However it fails using Nix master (https://github.com/NixOS/nix/commit/4e7f1c7f11fb22d7954b2dacbe87c61548fab82d):

$ git clone git://github.com/NixOS/nix
$ cd nix
$ nix-shell
$ ./bootstrap.sh
$ configurePhase
$ make
$ make install
$ inst/bin/nix repl
Welcome to Nix version 3.0. Type :? for help.
nix-repl> builtins.fetchGit { url = "..."; ref = "some-tag"; rev = "..."; }
fetching Git repository '...'fatal: couldn't find remote ref refs/heads/some-tag
error: --- Error ------------------------------------------------------------------------------------------------------------------------------------------------- nix
program 'git' failed with exit code 128

I do see that it works with: ref="refs/tags/some-tag":

nix-repl> builtins.fetchGit { url = ..."; ref = "refs/tags/some-tag"; rev = "..."; }
{ lastModified = ...; lastModifiedDate = "..."; narHash = "sha256-..."; outPath = "/nix/store/...-source"; rev = "..."; revCount = ...; shortRev = "..."; submodules = false; }

So maybe niv can switch to always using /refs/heads/<branch> for branches and /refs/tags/<tag> for tags.