Flake input schema: slash in branch name?

Hi all,

The wiki page offers the following syntax:
inputs.bar.url = "github:foo/bar/branch";.

Say I have a branch called “feature/something” in a GitLab repo. These throw the BadURL error:

  • inputs.bar.url = "gitlab:foo/bar/feature/something";
  • inputs.bar.url = "gitlab:foo/bar/-/tree/feature/something";

I also tried replacing the / in the branch name with %2F as a long shot, but alas…

Any thoughts before I go digging through the schema to determine whether this is currently possible?

Thanks!

This could maybe suffice as a workaround (untested)

inputs.bar.url = "git+https://gitlab.com/foo/bar.git?ref=feature/something";
1 Like

gitlab:owner/repo?ref=feature/simething should do as well and should also work with github and git URLs

Thank you for your helpful replies!

@hmenke This works. It should be noted, however, that the difference in URL syntax causes the whole repo to be refetched. For example, for a repo with feature/something as the default branch:

  1. Specify it as a flake input with the implicit gitlab:owner/repo syntax and build.
  2. Update the URL to specify the branch explicitly using the syntax you provided and rebuild.

The repo is fetched from the “new” URL, and the lock file is updated:

* Updated 'my-input': 'gitlab:owner/repo/6a47e8...' -> 'git+https://gitlab.com/owner/repo?ref=feature%2fsomething&rev=6a47e8...'

Talk about hermetic! :smile_cat:

@NobbZ The abbreviated syntax you suggested would be nice but throws BadURL for me, complaining that the URL contains an invalid branch/tag name.

Slashes in a branch name should be supported since libfetchers/github: allow slashes in refs by Ma27 · Pull Request #4115 · NixOS/nix · GitHub.

1 Like

Excellent! Thank you for your work on this.