flake-registry icon indicating copy to clipboard operation
flake-registry copied to clipboard

Add nixos versions to replace channels?

Open FRidh opened this issue 5 years ago • 5 comments

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.

FRidh avatar Oct 18 '20 14:10 FRidh

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 :-)

aszlig avatar Oct 24 '20 20:10 aszlig

$ 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 :)

FRidh avatar Oct 25 '20 09:10 FRidh

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.

asymmetric avatar Mar 08 '21 18:03 asymmetric

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

gytis-ivaskevicius avatar May 15 '21 17:05 gytis-ivaskevicius

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.

zimbatm avatar Apr 09 '23 09:04 zimbatm