As it stands, it seems that there’s a good chance that Flakes will be the future. Then where would channels and channels.nixos.org go? Here are some of my thoughts:
I feel that less reliance on GitHub for releases might be a good idea. If we decide to leave GitHub some day for some reason, it would be nice if we don’t suddenly leave countless mentions of github:NixOS/nixpkgs
lying around.
So maybe we should add a way to refer to channels in a Flake URL? Here’s a possible way that I thought of:
- When a user specifies an
http
/https
URL, and it leads to (possibly several) redirects, we instead record the final redirection destination inflake.lock
. - When a
flake.lock
is consulted to download the tarball, the URL inflake.lock
is used.
This way specifying:
inputs.nixpkgs.url = "https://nixos.org/channels/nixos-unstable/nixexprs.tar.xz";
Would actually just work, as instead of failing with an invalid hash whenever nixos-unstable
updates, it saves the redirected URL which points to a stable version. flake.nix
would look something like this:
{
"nodes": {
"nixpkgs": {
"locked": {
"narHash": "sha256-N1qI50AkeTSBp1ffUCHrcK2re52wrn6euFFGGvFa2iw=",
"type": "tarball",
"url": "https://releases.nixos.org/nixos/unstable/nixos-21.05pre269929.ff96a0fa563/nixexprs.tar.xz"
},
"original": {
"type": "tarball",
"url": "https://nixos.org/channels/nixos-unstable/nixexprs.tar.xz"
}
},
// ...
}
This way, older versions of Nix seeing this new lock file would just behave as if someone used --override-input
, and newer versions of Nix seeing the old lock file with the pre-redirection URL would simply migrate it over when nix flake update --update-input
is used.
A major concern would be whether this redirection is actually part of the intended interface of channels.nixos.org. That’s mainly why this is isn’t a feature request: It isn’t clear whether this even is a feature. I hope to generate some discussion here first.
In any case, I hope that channels.nixos.org doesn’t go away, if not just for a slightly independent place where nix expressions can be found.