2020-07-24 13:56:19 +03:00
|
|
|
|
# Name
|
2020-07-23 13:58:42 +03:00
|
|
|
|
|
2020-07-24 13:56:19 +03:00
|
|
|
|
`nix-channel` - manage Nix channels
|
2020-07-23 13:58:42 +03:00
|
|
|
|
|
2020-07-24 13:56:19 +03:00
|
|
|
|
# Synopsis
|
2020-07-23 13:58:42 +03:00
|
|
|
|
|
2021-05-13 20:33:03 +03:00
|
|
|
|
`nix-channel` {`--add` url [*name*] | `--remove` *name* | `--list` | `--update` [*names…*] | `--list-generations` | `--rollback` [*generation*] }
|
2020-07-23 13:58:42 +03: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 15:30:42 +03:00
|
|
|
|
- `--add` *url* \[*name*\]\
|
2020-07-23 15:28:05 +03: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 13:58:42 +03:00
|
|
|
|
|
2023-02-17 19:57:15 +02:00
|
|
|
|
A channel URL must point to a directory containing a file `nixexprs.tar.gz`.
|
|
|
|
|
At the top level, that tarball must contain a single directory with a `default.nix` file that serves as the channel’s entry point.
|
|
|
|
|
|
2021-04-23 15:30:42 +03:00
|
|
|
|
- `--remove` *name*\
|
2020-07-23 15:28:05 +03:00
|
|
|
|
Removes the channel named *name* from the list of subscribed
|
|
|
|
|
channels.
|
2020-07-23 13:58:42 +03:00
|
|
|
|
|
2021-04-23 15:30:42 +03:00
|
|
|
|
- `--list`\
|
2020-07-23 13:58:42 +03:00
|
|
|
|
Prints the names and URLs of all subscribed channels on standard
|
|
|
|
|
output.
|
|
|
|
|
|
2021-04-23 15:30:42 +03:00
|
|
|
|
- `--update` \[*names*…\]\
|
2020-07-23 13:58:42 +03:00
|
|
|
|
Downloads the Nix expressions of all subscribed channels (or only
|
2020-07-23 15:28:05 +03: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 13:58:42 +03:00
|
|
|
|
`~/.nix-defexpr`).
|
|
|
|
|
|
2021-05-13 20:33:03 +03:00
|
|
|
|
- `--list-generations`\
|
|
|
|
|
Prints a list of all the current existing generations for the
|
|
|
|
|
channel profile.
|
|
|
|
|
|
|
|
|
|
Works the same way as
|
|
|
|
|
```
|
|
|
|
|
nix-env --profile /nix/var/nix/profiles/per-user/$USER/channels --list-generations
|
|
|
|
|
```
|
|
|
|
|
|
2021-04-23 15:30:42 +03:00
|
|
|
|
- `--rollback` \[*generation*\]\
|
2020-07-23 13:58:42 +03: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`.
|
|
|
|
|
|
2023-03-23 17:27:41 +02:00
|
|
|
|
{{#include ./opt-common.md}}
|
|
|
|
|
|
|
|
|
|
{{#include ./env-common.md}}
|
|
|
|
|
|
2023-05-15 16:26:14 +03:00
|
|
|
|
# Files
|
|
|
|
|
|
|
|
|
|
`nix-channel` operates on the following files.
|
|
|
|
|
|
|
|
|
|
{{#include ./files/channels.md}}
|
|
|
|
|
|
2020-07-23 13:58:42 +03:00
|
|
|
|
# Examples
|
|
|
|
|
|
|
|
|
|
To subscribe to the Nixpkgs channel and install the GNU Hello package:
|
|
|
|
|
|
2020-07-31 16:43:25 +03:00
|
|
|
|
```console
|
|
|
|
|
$ nix-channel --add https://nixos.org/channels/nixpkgs-unstable
|
|
|
|
|
$ nix-channel --update
|
2023-04-30 16:52:38 +03:00
|
|
|
|
$ nix-env --install --attr nixpkgs.hello
|
2020-07-31 16:43:25 +03:00
|
|
|
|
```
|
2020-07-23 13:58:42 +03:00
|
|
|
|
|
|
|
|
|
You can revert channel updates using `--rollback`:
|
|
|
|
|
|
2020-07-31 16:43:25 +03:00
|
|
|
|
```console
|
2023-04-30 16:52:38 +03:00
|
|
|
|
$ nix-instantiate --eval --expr '(import <nixpkgs> {}).lib.version'
|
2020-07-31 16:43:25 +03:00
|
|
|
|
"14.04.527.0e935f1"
|
2020-07-24 13:56:19 +03:00
|
|
|
|
|
2020-07-31 16:43:25 +03:00
|
|
|
|
$ nix-channel --rollback
|
|
|
|
|
switching from generation 483 to 482
|
2020-07-24 13:56:19 +03:00
|
|
|
|
|
2023-04-30 16:52:38 +03:00
|
|
|
|
$ nix-instantiate --eval --expr '(import <nixpkgs> {}).lib.version'
|
2020-07-31 16:43:25 +03:00
|
|
|
|
"14.04.526.dbadfad"
|
|
|
|
|
```
|