I don’t think its possible to do it like you expect it to. For eg. nixos/nix provides GitHub - NixOS/nix at latest-release a branch specifically tracking latest release, so that github:nixos/nix/latest-release can be used. or GitHub - cachix/cachix at latest which is a duplicated tag the upstream provides.
So the upstream project needs to maintain something similar or you have to maintain a fork yourself with a branch which tracks the latest release.
That is not possible, at the moment, unless the target repository has a branch tracking the latest release. FWIW, I did start hacking on a simple server that works similar to Flakehub’s semver resolution thingy, but only needs a git repository with semver-like tags as backend (but that server would still need to be running somewhere). No README, but feel free to look around:
Do you think it would be possible to make an utils for flake inputs that would be able to infer the latest release of a repository and chose it as an input target? potentially using the GitHub API
As of now at least, GitHub has no official API to obtain the latest created tag. It can pull the latest release, which for some repos will match the latest tag.
The topmost entry from the result object this endpoint returns seems to always refer to the latest tag
I tried /repos/{owner}/{repo}/tags/latest (similar to the releases/latest one), but it doesn’t seem to exist (but it is more acceptable given than releases has a concrete “latest” one, while it’s not a thing for tags)
Also, I couldn’t yet find which parameters / options could this endpoint take, so also couldn’t find a way for it to only return the latest tag for efficiency (maybe using a similar GraphQL endpoint?)
For now, I was only successful in listing every tags at once from a repository
This is indeed true, there are two endpoints making that possible:
You definetly could write a wrapper around nix flake update to implement your desired tag-following semantics and rewrites the flake.nix inputs just before you run nix flake update
The returned list is ordered by the tag creation date (exactly in the same order than results from this page for example : Tags · NixOS/nix · GitHub), and not by SemVer
So there is a way to use the two global pagination parameters from their API (Using pagination in the REST API - GitHub Docs) to make it so you only return the latest pushed tag, but it wouldn’t guarantee it would also be the latest semver tag
Sure, that should work! As long as it’s a branch you want to track, it doesn’t matter if that’s coming from an automatically synced fork or upstream.