Nix flake gitlab HTTP 404 error


I am preparing my first flake (using the template from nix flake init -t templates#rust) and

nix flake metadata gitlab:user/group/subgroup/package
nix shell gitlab:user/group/subgroup/package

both fail with

error: unable to download '': HTTP error 404 ('')

which is suggestive of the problem … but I am not sure how to solve.

The following succeeds:

nix flake metadata 'git+'
nix shell 'git+'

Any guidance on how to get the first way working is appreciated!

This most likely means that you’re trying to use a private repository. For that to work, Nix will need a netrc file. Take a look at Enterprise - NixOS Wiki - it only mentions fetchurl, but the same mechanism is used for flakes as well.

1 Like

The gitlab schema does not correctly work with subgroups. The subgroups are parsed as branch…

Using gitlab:user/group%2Fsubgroup%2Fpackage might work, though it might as well happen that the percentsigns are escaped then… You need to try it out…

I also was under the impression that there has been a bug report about that, but I can not find it right now, though if Leverage the "uniform" in URLs for flake refs more · Issue #6304 · NixOS/nix · GitHub would get implemented, gitlab subgroups would be fixed as a drive by, due to the strict question for making ref a query parameter and not allow it in the path anymore.


Yes, your proposal here Leverage the "uniform" in URLs for flake refs more · Issue #6304 · NixOS/nix · GitHub would address my issue. Thanks.