Flake input fails when all "git+ssh", "ref=", and "dir=" are used

The following command behaves differently on nixos and nix darwin:
nix flake metadata git+ssh://git@github.com/mygh/myrepo?ref=mybranch&dir=mysubdir.

On darwin, this correctly finds the flake in subdir and returns what I expect from nix flake metadata. However, on nixos – I get a 404. After some debugging, I found that the ?dir= part of the command doesn’t seem to get stripped for the nixos git invocation (the debug logs show fetching Git repository: 'ssh://git@github.com/.../myrepo.git?dir=subdir followed by is not a valid repository name)

Output of nix --version on both systems?

So it looks like this is the relevant gh issue: nix flake clone fails on a remote flake with a dir parameter · Issue #12417 · NixOS/nix · GitHub, it was fixed in nix 2.26, but nix unstable is still on 2.24

Yeah, I forgot to reply here. Use nix 2.26 (unstable), nix 2.18 (currently stable but only available on nixos-24.11 branch), or lix.

1 Like