Could this be elaborated, and do other Nix proficient people agree?
What could be the potential tradeoff of doing that?
I think remembering over the vast majority of the nix flakes configuration I have seen, nixpkgs inputs were almost always using a version of a github:NixOS/nixpkgs URLs (and some using nixpkgs FlakeHub URLs)
I don’t think I have seen it recommended in the wiki either (but probably should if that is correct)
It seems like an interesting and bold claim
Also, about the benefits you are talking about:
Are those benefits not possible to be worked on and added for git urls?
I am thinking of a fallback to trusted artifacts sources in case of a rate-limit / censor
The way I understand nix’ CI infrastructure (from reading these docs apparently) and branching strategy things go roughly as follows:
A commit is pushed to the respective dev branch (master or release-YY.MM).
Hydra eventually picks up the commit and starts building packages and tests.
Hydra completes
Upon completion, hydra:
Produces the release tarball
This contains the relevant command-not-found cache (and man cache?)
Hydra fast-forwards the respective non-dev branch (nix(os|pkgs)-unstable or nixos-YY.MM)
There are sub-points to the CI completion that trigger the *-small and *-darwin releases
As such, the release tarballs are more complete, aren’t subject to the same rate limits and censorship as GitHub (which have caused many folks headaches in the past), and mean actually using the nixpkgs infrastructure as intended. You can build from the branches, but those are downstream from the release tarballs and you get less complete artifacts.
Older versions of nix won’t be able to resolve the input correctly, though they should interpret the lockfile correctly I think? Other than that, none, you’re just using nixpkgs as intended, before the limitations of flakes resulted in people using the git repo directly instead of the release tarballs. I.e., you’re getting the same stuff nix-channel used to download.
CDN details change, too, I suppose, but the tarball is ~40MB, while the shallow git repo is ~80MB compressed, so you’d have to have a pretty bad connection to NixOS infra to have overall slower downloads than from GitHub.
This feature only came into existence a few months ago. You’re looking at half a decade’s worth of ecosystem. Of course not all of the above have updated, nor has your memory retroactively inserted a feature that didn’t exist. The fact that this is even possible hasn’t been remotely advertised beyond that PR either, so the vast majority of the community will be as unaware as I was.
It’s not exactly intuitive behavior, normally a url doesn’t magically resolve to a different location at flake resolution time, so I don’t think anyone would be looking for this either unless they scanned the nix release notes and understood what the feature name meant at a glance. I imagine this passed by most of us.
Not really, since the command-not-found (and man?) cache fundamentally has to be produced during the build, so it cannot reasonably be committed, and the cleanup steps involved in reducing the tarball size most likely involve removing dev-only cruft from the repo.
Using git for release versioning is anyway a bit of a hack, this is much nicer IMO.
Overall, really awesome work from detsys, thank you @grahamc & co for upstreaming this. It’s technically a small fix, but if we can get over the collective inertia I think this has significant impact. Even just the emission savings from cutting all nixpkgs update downloads in half matters.
Nope! It’s not clear how version resolution could possibly happen in the Nix CLI itself with respect to a platform like GitHub, which doesn’t expose the proper hooks for such resolution.
What we did is we upstreamed a change to Nix that would make not just FlakeHub with SemVer possible but also an indefinite number of platforms and URL schemes. Set up an HTTP server that provides responses that the Nix CLI understands and boom, you’ve got yourself a flake resolution scheme of whatever complexity and serving whatever use cases you like. We liked how Rust and Cargo do things so we brought it to Nix, and people can use it for free (for public flakes). Nothing is stopping anyone from doing an entirely different thing.
FlakeHub serves statically generated tarballs. They’re created once, and then archived in read-only storage forever. That means that changes to tar creation or compression will never cause the hashes to change.
I disagree, as that breaks user expectations. Nix shouldn’t translate our inputs from one thing to another arbitrarily, that should be a conscious decision by the user.
What are there to expect about nixpkgs input which could make this enhancement a deal breaker?
The current github repository input is technically also breaking expectations because its redirecting to a tarball, which is a direct enhancement and also if I’m not mistaken was not present from day one and required “breaking user expectations” to implement
Given @TLATER’s downsides analysis, I’m quite optimistic
Alternatively, do you think an hydra: / nixpkgs: / nixos: / channel: input type or something similar would be preferable?
FWIW, iirc determinate nix actually does support the channel: syntax. (edit: nevermind, that was for non-flakes only, and regular nix supports it too.) And the extracted tarballs are flakes, so it could be supported via flakes.