Open lheckemann opened 4 years ago
Does following the nixos-20.03
branch not achieve this already?
No — compare
nix eval -f https://github.com/nixos/nixpkgs/archive/nixos-20.03.tar.gz lib.version
and
nix eval -f https://nixos.org/channels/nixos-20.03/nixexprs.tar.xz lib.version
This information can be very helpful for tracing back from e.g. a nixos system built with the nixpkgs in question.
Aren't channels being phased out in favor of flakes? I've never really used channels, how does that work? I.e., how would the CLI UX look like?
In the case of niv, I imagine it wouldn't look any different than any other dependencies — just that rather than having url_template
, owner
, repo
, etc, one would have a "current URL" like https://nixos.org/channels/nixos-20.03/nixexprs.tar.xz
and a "pinned URL" like https://releases.nixos.org/nixos/20.03/nixos-20.03.1577.74a80c5a9ab/nixexprs.tar.xz
(not sure about the naming here). The pinned URL is obtained by following the redirects at the current URL.
As for replacement by flakes, there are unfortunately two different concepts called channels here…
nix-channel
, which is suboptimal UX-wise and should indeed be replaced by flakes AFAIU (but wouldn't flakes also be an alternative to niv?)That said, it's just a suggestion and I'm content with my ugly little shell script instead of niv for pinning my nixops deployment's nixpkgs, so maybe you want to implement it if you'd find it useful yourself, but I'm happy as is too :)
EDIT: CLI could look something like niv add --channel https://nixos.org/channels/nixos-20.03
or niv add --channel https://nixos.org/channels/nixos-20.03/nixexprs.tar.xz
@lheckemann don't you get the right lib.version
when using https://github.com/NixOS/nixpkgs-channels/archive
?
For instance nix eval -f https://github.com/NixOS/nixpkgs-channels/archive/5272327b81ed355bbed5659b8d303cf2979b6953.tar.gz lib.version
.
nixpkgs-channels
is deprecated, the channel branches from there are now just branches in the main nixpkgs
repo. The command you give has the same output as the one @lheckemann posted using the git repo, which is different to the one from the channel archive.
Yes, as @michaelpj says. Specifically, the channel tarball is generated by https://github.com/NixOS/nixpkgs/blob/master/nixos/lib/make-channel.nix which includes some extra metadata which makes displaying the correct version possible. This metadata can't be obtained from github's tarball, as said tarball is generated directly from the git tree.
@michaelpj @lheckemann thanks for your input. That's good to know.
Also the channels contain programs.sqlite which I want on a non nixos system.
Using nixpkgs's release channel tarballs (https://nixos.org/channels/nixos-20.03/nixexprs.tar.xz for example) has the advantage of including the nixpkgs version in nixpkgs's
lib.version
and of being a "release" of sorts. Support for this would be nice.