2020-07-24 10:56:19 +00:00
|
|
|
|
# Name
|
2020-07-23 10:58:42 +00:00
|
|
|
|
|
2020-07-24 10:56:19 +00:00
|
|
|
|
`nix-channel` - manage Nix channels
|
2020-07-23 10:58:42 +00:00
|
|
|
|
|
2020-07-24 10:56:19 +00:00
|
|
|
|
# Synopsis
|
2020-07-23 10:58:42 +00:00
|
|
|
|
|
2020-07-24 10:56:19 +00:00
|
|
|
|
`nix-channel` {`--add` url [*name*] | `--remove` *name* | `--list` | `--update` [*names…*] | `--rollback` [*generation*] }
|
2020-07-23 10:58:42 +00:00
|
|
|
|
|
|
|
|
|
# Description
|
|
|
|
|
|
|
|
|
|
A Nix channel is a mechanism that allows you to automatically stay
|
|
|
|
|
up-to-date with a set of pre-built Nix expressions. A Nix channel is
|
|
|
|
|
just a URL that points to a place containing a set of Nix expressions.
|
|
|
|
|
|
|
|
|
|
To see the list of official NixOS channels, visit
|
|
|
|
|
<https://nixos.org/channels>.
|
|
|
|
|
|
|
|
|
|
This command has the following operations:
|
|
|
|
|
|
2021-04-23 12:30:42 +00:00
|
|
|
|
- `--add` *url* \[*name*\]\
|
2020-07-23 12:28:05 +00:00
|
|
|
|
Adds a channel named *name* with URL *url* to the list of subscribed
|
|
|
|
|
channels. If *name* is omitted, it defaults to the last component of
|
|
|
|
|
*url*, with the suffixes `-stable` or `-unstable` removed.
|
2020-07-23 10:58:42 +00:00
|
|
|
|
|
2021-04-23 12:30:42 +00:00
|
|
|
|
- `--remove` *name*\
|
2020-07-23 12:28:05 +00:00
|
|
|
|
Removes the channel named *name* from the list of subscribed
|
|
|
|
|
channels.
|
2020-07-23 10:58:42 +00:00
|
|
|
|
|
2021-04-23 12:30:42 +00:00
|
|
|
|
- `--list`\
|
2020-07-23 10:58:42 +00:00
|
|
|
|
Prints the names and URLs of all subscribed channels on standard
|
|
|
|
|
output.
|
|
|
|
|
|
2021-04-23 12:30:42 +00:00
|
|
|
|
- `--update` \[*names*…\]\
|
2020-07-23 10:58:42 +00:00
|
|
|
|
Downloads the Nix expressions of all subscribed channels (or only
|
2020-07-23 12:28:05 +00:00
|
|
|
|
those included in *names* if specified) and makes them the default
|
|
|
|
|
for `nix-env` operations (by symlinking them from the directory
|
2020-07-23 10:58:42 +00:00
|
|
|
|
`~/.nix-defexpr`).
|
|
|
|
|
|
2021-04-23 12:30:42 +00:00
|
|
|
|
- `--rollback` \[*generation*\]\
|
2020-07-23 10:58:42 +00:00
|
|
|
|
Reverts the previous call to `nix-channel
|
|
|
|
|
--update`. Optionally, you can specify a specific channel generation
|
|
|
|
|
number to restore.
|
|
|
|
|
|
|
|
|
|
Note that `--add` does not automatically perform an update.
|
|
|
|
|
|
|
|
|
|
The list of subscribed channels is stored in `~/.nix-channels`.
|
|
|
|
|
|
|
|
|
|
# Examples
|
|
|
|
|
|
|
|
|
|
To subscribe to the Nixpkgs channel and install the GNU Hello package:
|
|
|
|
|
|
2020-07-31 13:43:25 +00:00
|
|
|
|
```console
|
|
|
|
|
$ nix-channel --add https://nixos.org/channels/nixpkgs-unstable
|
|
|
|
|
$ nix-channel --update
|
|
|
|
|
$ nix-env -iA nixpkgs.hello
|
|
|
|
|
```
|
2020-07-23 10:58:42 +00:00
|
|
|
|
|
|
|
|
|
You can revert channel updates using `--rollback`:
|
|
|
|
|
|
2020-07-31 13:43:25 +00:00
|
|
|
|
```console
|
|
|
|
|
$ nix-instantiate --eval -E '(import <nixpkgs> {}).lib.version'
|
|
|
|
|
"14.04.527.0e935f1"
|
2020-07-24 10:56:19 +00:00
|
|
|
|
|
2020-07-31 13:43:25 +00:00
|
|
|
|
$ nix-channel --rollback
|
|
|
|
|
switching from generation 483 to 482
|
2020-07-24 10:56:19 +00:00
|
|
|
|
|
2020-07-31 13:43:25 +00:00
|
|
|
|
$ nix-instantiate --eval -E '(import <nixpkgs> {}).lib.version'
|
|
|
|
|
"14.04.526.dbadfad"
|
|
|
|
|
```
|
2020-07-23 10:58:42 +00:00
|
|
|
|
|
|
|
|
|
# Files
|
|
|
|
|
|
2021-04-23 12:30:42 +00:00
|
|
|
|
- `/nix/var/nix/profiles/per-user/username/channels`\
|
2020-07-23 10:58:42 +00:00
|
|
|
|
`nix-channel` uses a `nix-env` profile to keep track of previous
|
|
|
|
|
versions of the subscribed channels. Every time you run `nix-channel
|
|
|
|
|
--update`, a new channel generation (that is, a symlink to the
|
|
|
|
|
channel Nix expressions in the Nix store) is created. This enables
|
|
|
|
|
`nix-channel --rollback` to revert to previous versions.
|
|
|
|
|
|
2021-04-23 12:30:42 +00:00
|
|
|
|
- `~/.nix-defexpr/channels`\
|
2020-07-23 10:58:42 +00:00
|
|
|
|
This is a symlink to
|
|
|
|
|
`/nix/var/nix/profiles/per-user/username/channels`. It ensures that
|
|
|
|
|
`nix-env` can find your channels. In a multi-user installation, you
|
|
|
|
|
may also have `~/.nix-defexpr/channels_root`, which links to the
|
|
|
|
|
channels of the root user.
|
|
|
|
|
|
|
|
|
|
# Channel format
|
|
|
|
|
|
|
|
|
|
A channel URL should point to a directory containing the following
|
|
|
|
|
files:
|
|
|
|
|
|
2021-04-23 12:30:42 +00:00
|
|
|
|
- `nixexprs.tar.xz`\
|
2020-07-23 10:58:42 +00:00
|
|
|
|
A tarball containing Nix expressions and files referenced by them
|
|
|
|
|
(such as build scripts and patches). At the top level, the tarball
|
|
|
|
|
should contain a single directory. That directory must contain a
|
|
|
|
|
file `default.nix` that serves as the channel’s “entry point”.
|