Nixpkgs: A simple command to wrap any folder as a nix channel

Created on 14 Apr 2016  Â·  13Comments  Â·  Source: NixOS/nixpkgs

Currently nix-channel expects a URI to a resource containing 2 things. A nixexprs.tar.xz and a file binary-cache-url.

There doesn't seem to be a nix-* command that can easily and automatically take any nix expression folder or expression and wrapping it up, satisfying the channel format.

I reckon such a command would be quite useful. And especially since nix-channel can use file:// protocol for local filesystem. This would make custom channels super easy to create.

I would also prefer nix-channel to verify the signature of the channel assuming I have it available with already.

I'll be looking to create this command just using bash script. But this might be useful to integrate into the existing nix utilities. In which case will require C++ instead.

Most helpful comment

@CMCDragonkai I generate a channel-like tarball with

$ nix-build nixos/release.nix -A channel --arg nixpkgs  '{ outPath = ./. ; revCount = "'$(git rev-list HEAD | wc -l)'"; shortRev = "'$(git rev-parse --short HEAD)'"; }'
...
/nix/store/hash-name/
$ sudo nix-channel --remove nixos
$ sudo nix-channel --add file:///nix/store/hash-name/tarballs/thetarball.tar.xz nixos
$ sudo nix-channel --update

I am quite sure this is not perfect (the tarball is unpacked then re-packed), but it gives you a hint of how it could work.

Otherwise, using hydra seems the canonical way to go.

All 13 comments

I wonder, what is the reason for wanting this instead of setting NIX_PATH=nixpkgs=? Also, I don't think this is a nixpkgs issue per se.

You can then allow other people to use it (over the net), and setup a generation timeline for a local package set.

Oh and nix-env doesn't respect NIX_PATH.
On 16/04/2016 2:12 AM, "joachifm" [email protected] wrote:

I wonder, what is the reason for wanting this instead of setting
NIX_PATH=nixpkgs=? Also, I don't think this is a nixpkgs issue per se.

—
You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
https://github.com/NixOS/nixpkgs/issues/14698#issuecomment-210524576

In what sense does it not?

Are you aware that nix-env -f accepts any URL pointing to a nixexprs archive? If you need to use different or additional binary caches, that is covered by nix.conf or options (depending on your setup). To me, channels appear to be all but obsolete. Then again, I have simple needs (I asked why you needed this out of curiousity, not to dismiss the issue, just to be clear).

Here
http://lethalman.blogspot.com.au/2014/09/nix-pill-15-nix-search-paths.html?m=1
On 16/04/2016 6:24 PM, "joachifm" [email protected] wrote:

In what sense does it not?

—
You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
https://github.com/NixOS/nixpkgs/issues/14698#issuecomment-210766074

Yea so I know about -f. Channels appear to be a moving target kind of
package set. Similar to rolling releases.
On 16/04/2016 6:30 PM, "joachifm" [email protected] wrote:

Are you aware that nix-env -f accepts any URL pointing to a nixexprs
archive? If you need to use different or additional binary caches, that is
covered by nix.conf or options (depending on your setup). To me, channels
appear to be all but obsolete. Then again, I have simple needs (I asked why
you needed this out of curiousity, not to dismiss the issue, just to be
clear).

—
You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
https://github.com/NixOS/nixpkgs/issues/14698#issuecomment-210768317

The proposal for the new command line tool might interest you.
There is a mention about dropping the channels and use $NIX_PATH instead.

Yep, I've commented on that already. However using NIX_PATH is quite a different thing from channels. Channels represent a moving target of sorts, similar to other distro (rolling releases), but enhanced with generation timelines. Channels also allow merging of different channels (merging your own private channel too), which is again similar to things like having a PPA in Ubuntu. It's a different kind of workflow. Not content addressable, but still useful for not-so-technical users who are coming from other distros.

@CMCDragonkai I generate a channel-like tarball with

$ nix-build nixos/release.nix -A channel --arg nixpkgs  '{ outPath = ./. ; revCount = "'$(git rev-list HEAD | wc -l)'"; shortRev = "'$(git rev-parse --short HEAD)'"; }'
...
/nix/store/hash-name/
$ sudo nix-channel --remove nixos
$ sudo nix-channel --add file:///nix/store/hash-name/tarballs/thetarball.tar.xz nixos
$ sudo nix-channel --update

I am quite sure this is not perfect (the tarball is unpacked then re-packed), but it gives you a hint of how it could work.

Otherwise, using hydra seems the canonical way to go.

Thank you for your contributions.

This has been automatically marked as stale because it has had no activity for 180 days.

If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity.

Here are suggestions that might help resolve this more quickly:

  1. Search for maintainers and people that previously touched the related code and @ mention them in a comment.
  2. Ask on the NixOS Discourse.
  3. Ask on the #nixos channel on irc.freenode.net.

still important to me

@ZerataX I am a new user for NixOS, and also encounter the similar problem. Here is the script I use, it maybe good for you too.
https://github.com/yanganto/parachutes/blob/master/bin/nix-folder2channel

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rzetterberg picture rzetterberg  Â·  3Comments

teto picture teto  Â·  3Comments

ob7 picture ob7  Â·  3Comments

retrry picture retrry  Â·  3Comments

chris-martin picture chris-martin  Â·  3Comments