flake-registry
                                
                                 flake-registry copied to clipboard
                                
                                    flake-registry copied to clipboard
                            
                            
                            
                        Add nixos versions to replace channels?
The idea of flakes is to also replace channels. In a flake, one can choose what nixpkgs url to use. When not working with a local flake, one can invoke e.g.
nix shell nixpkgs#hello
If one wants a version from 20.09, one needs to use
$ nix shell nixpkgs#hello --override-input nixpkgs github:nixos/nixpkgs/nixos-20.09
It would be convenient if there would be registry entries for all stable versions so one could write
nix shell nixos-20.09#hello
We do need to draw a line here because we can't add all branches of whatever project. Also, it's not bad having to learn to use override-input. And, it prevents users from relying specifically on nixos-20.09 in a flake.nix where maybe they should not.
I do not know whether we should add the stable versions or not, but I can imagine here the convenience outweighs the disadvantages.
If one wants a version from 20.09, one needs to use
$ nix shell nixpkgs#hello --override-input nixpkgs github:nixos/nixpkgs/nixos-20.09
Why not use this instead?
$ nix shell nixpkgs/nixos-20.09#hello
But in general, I agree that just writing nixos-20.09#hello is much shorter :-)
$ nix shell nixpkgs/nixos-20.09#hello
I did not imagine this to work, actually! It was my impression nixpkgs in the global registry would point to a certain branch already.
From the registry file
      "from": {
        "id": "nixpkgs",
        "type": "indirect"
      },
      "to": {
        "owner": "NixOS",
        "repo": "nixpkgs",
        "type": "github"
      }
it seems no branch is selected. I was under the impression at least a channel was chosen.
Checking what nixpkgs resolves to
$ nix flake info nixpkgs
Resolved URL:  github:NixOS/nixpkgs
Locked URL:    github:NixOS/nixpkgs/d82188bf90f70880229a746b6dfd666a53f85b50
Description:   A collection of packages for the Nix package manager
Path:          /nix/store/1gzaxqrpydlwbbvnak4z5h5vkmp449i3-source
Revision:      d82188bf90f70880229a746b6dfd666a53f85b50
Last modified: 2020-10-25 09:52:22
$ nix flake info nixpkgs/nixos-20.09
Resolved URL:  github:NixOS/nixpkgs/nixos-20.09
Locked URL:    github:NixOS/nixpkgs/95d26c9a9f2a102e25cf318a648de44537f42e09
Description:   A collection of packages for the Nix package manager
Path:          /nix/store/wgzfnwgrrj8ach2kc971yw1vvr0fvsqs-source
Revision:      95d26c9a9f2a102e25cf318a648de44537f42e09
Last modified: 2020-10-24 10:37:53
Bare nixpkgs corresponds to master, that's something to keep in mind :)
Independentlty of the appropriate invocation syntax, I do agree that the registry could ship with current stable + nixos-unstable as sensible defaults - and make do with the custom entries, e.g. github:edolstra and github:DavHau.
This sounds neat but here is a little idea to consider:
Maybe it is worth renaming nixos-unstable to nixos-rolling or something along those lines just to make it more newbie-friendly?
Especially now with flakes, it is so obvious that one can just rollback channel by simply git restore flake.lock. There is no need to even know about --rollback flag
Just a thought, possibly RFC material, but yeah, might be worth considering
One hiccup is that Nix considers that keys with a dot must be a path, and doesn't look them up even if they are in the registry.