Nix: URL parsing when using fetchGit does not accept the SSH URL that Github suggests anymore

Created on 16 Apr 2020  路  3Comments  路  Source: NixOS/nix

See the following example.

With 2.3.4:

nix-repl> builtins.fetchGit { url = "[email protected]:RelationalAI/myrepo.git"; }
{ outPath = "/nix/store/ls6m...-source"; rev = "..."; revCount = ...; shortRev = "..."; }

With latest master:

nix-repl> builtins.fetchGit { url = "[email protected]:RelationalAI/myrepo.git"; }
error: 'file://[email protected]:RelationalAI/myrepo.git' is not a valid URL

Most helpful comment

Btw, using ssh://[email protected]/RelationalAI/myrepo.git does work both in 2.3.4 and latest master.

All 3 comments

Btw, using ssh://[email protected]/RelationalAI/myrepo.git does work both in 2.3.4 and latest master.

Support for git@... URLs is even documented:

$ nix repl
warning: unknown setting 'extra-sandbox-paths'
Welcome to Nix version 2.4pre20201102_550e11f. Type :? for help.

nix-repl> :doc fetchGit
[...]
    Here are some examples of how to use fetchGit.

  - To fetch a private repository over SSH:

          builtins.fetchGit {
            url = "[email protected]:my-secret/repository.git";
            ref = "master";
            rev = "adab8b916a45068c044658c4158d81878f9ed1c3";
          }
[...]
nix-repl> builtins.fetchGit {
                      url = "[email protected]:my-secret/repository.git";
                      ref = "master";
                      rev = "adab8b916a45068c044658c4158d81878f9ed1c3";
                    }
error: --- BadURL ------------------------------------------------------------------------------------ nix
'file://[email protected]:my-secret/repository.git' is not a valid URL

I'm trying to use Nix at $dayjob and currently have to work around this :-(

I have looked at the code and while removing the file:// prefix is doable (for me), I see that Nix is really wants that string to be an _URL_ (it calls parseURL() from more than one place). But what we want here is the scp semi-URL format [user@]host:path.

It feels a bit ugly to make parseURL() accept the scp format, but I don't know what else to do. (Nix also wants to check the inputs for the allowed-uris functionality, so we cannot simply _drop_ checking the input string either.)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ericsagnes picture ericsagnes  路  4Comments

Infinisil picture Infinisil  路  3Comments

matthewbauer picture matthewbauer  路  3Comments

copumpkin picture copumpkin  路  3Comments

bgamari picture bgamari  路  3Comments