forked from lix-project/lix
remove the Channels section
this is a how-to guide which should not be in the reference manual. it also refers to `nix-env`, which should not be the first thing readers of the reference manual encounter, as it behaves very differently in spirit from the rest of Nix. slightly reword the documentation to be more concise and informative.
This commit is contained in:
parent
a8d5bb5e7e
commit
ee72ede389
|
@ -21,7 +21,6 @@
|
||||||
- [Profiles](package-management/profiles.md)
|
- [Profiles](package-management/profiles.md)
|
||||||
- [Garbage Collection](package-management/garbage-collection.md)
|
- [Garbage Collection](package-management/garbage-collection.md)
|
||||||
- [Garbage Collector Roots](package-management/garbage-collector-roots.md)
|
- [Garbage Collector Roots](package-management/garbage-collector-roots.md)
|
||||||
- [Channels](package-management/channels.md)
|
|
||||||
- [Sharing Packages Between Machines](package-management/sharing-packages.md)
|
- [Sharing Packages Between Machines](package-management/sharing-packages.md)
|
||||||
- [Serving a Nix store via HTTP](package-management/binary-cache-substituter.md)
|
- [Serving a Nix store via HTTP](package-management/binary-cache-substituter.md)
|
||||||
- [Copying Closures via SSH](package-management/copy-closure.md)
|
- [Copying Closures via SSH](package-management/copy-closure.md)
|
||||||
|
|
|
@ -8,36 +8,41 @@
|
||||||
|
|
||||||
# Description
|
# Description
|
||||||
|
|
||||||
A Nix channel is a mechanism that allows you to automatically stay
|
Channels are a mechanism for referencing remote Nix expressions and conveniently retrieving their latest version.
|
||||||
up-to-date with a set of pre-built Nix expressions. A Nix channel is
|
For the list of official channels, visit <https://nixos.org/channels>.
|
||||||
just a URL that points to a place containing a set of Nix expressions.
|
|
||||||
|
|
||||||
To see the list of official NixOS channels, visit
|
> **Note**
|
||||||
<https://nixos.org/channels>.
|
>
|
||||||
|
> The state of a subscribed channel is external to the Nix expressions relying on it.
|
||||||
|
> This may limit reproducibility.
|
||||||
|
>
|
||||||
|
> Dependencies on other Nix expressions can be declared explicitly with:
|
||||||
|
> - [`fetchurl`](@docroot@/language/builtins.md#builtins-fetchurl), [`fetchTarball`](@docroot@/language/builtins.md#builtins-fetchTarball), or [`fetchGit`](@docroot@/language/builtins.md#builtins-fetchGit) in Nix expressions
|
||||||
|
> - the [`-I` option](@docroot@/command-ref/opt-common.md#opt-I) in command line invocations
|
||||||
|
|
||||||
This command has the following operations:
|
This command has the following operations:
|
||||||
|
|
||||||
- `--add` *url* \[*name*\]\
|
- `--add` *url* \[*name*\]\
|
||||||
Adds a channel named *name* with URL *url* to the list of subscribed
|
Add a channel *name* located at *url* to the list of subscribed channels.
|
||||||
channels. If *name* is omitted, it defaults to the last component of
|
If *name* is omitted, default to the last component of *url*, with the suffixes `-stable` or `-unstable` removed.
|
||||||
*url*, with the suffixes `-stable` or `-unstable` removed.
|
|
||||||
|
> **Note**
|
||||||
|
>
|
||||||
|
> `--add` does not automatically perform an update.
|
||||||
|
> Use `--update` explicitly.
|
||||||
|
|
||||||
A channel URL must point to a directory containing a file `nixexprs.tar.gz`.
|
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.
|
At the top level, that tarball must contain a single directory with a `default.nix` file that serves as the channel’s entry point.
|
||||||
|
|
||||||
- `--remove` *name*\
|
- `--remove` *name*\
|
||||||
Removes the channel named *name* from the list of subscribed
|
Remove the channel *name* from the list of subscribed channels.
|
||||||
channels.
|
|
||||||
|
|
||||||
- `--list`\
|
- `--list`\
|
||||||
Prints the names and URLs of all subscribed channels on standard
|
Print the names and URLs of all subscribed channels on standard output.
|
||||||
output.
|
|
||||||
|
|
||||||
- `--update` \[*names*…\]\
|
- `--update` \[*names*…\]\
|
||||||
Downloads the Nix expressions of all subscribed channels (or only
|
Download the Nix expressions of subscribed channels and create a new generation.
|
||||||
those included in *names* if specified) and makes them the default
|
Update all channels if none is specified, and only those included in *names* otherwise.
|
||||||
for `nix-env` operations (by symlinking them from the directory
|
|
||||||
`~/.nix-defexpr`).
|
|
||||||
|
|
||||||
- `--list-generations`\
|
- `--list-generations`\
|
||||||
Prints a list of all the current existing generations for the
|
Prints a list of all the current existing generations for the
|
||||||
|
@ -49,13 +54,8 @@ This command has the following operations:
|
||||||
```
|
```
|
||||||
|
|
||||||
- `--rollback` \[*generation*\]\
|
- `--rollback` \[*generation*\]\
|
||||||
Reverts the previous call to `nix-channel
|
Revert channels to the state before the last call to `nix-channel --update`.
|
||||||
--update`. Optionally, you can specify a specific channel generation
|
Optionally, you can specify a specific channel *generation* number to restore.
|
||||||
number to restore.
|
|
||||||
|
|
||||||
Note that `--add` does not automatically perform an update.
|
|
||||||
|
|
||||||
The list of subscribed channels is stored in `~/.nix-channels`.
|
|
||||||
|
|
||||||
{{#include ./opt-common.md}}
|
{{#include ./opt-common.md}}
|
||||||
|
|
||||||
|
@ -69,23 +69,33 @@ The list of subscribed channels is stored in `~/.nix-channels`.
|
||||||
|
|
||||||
# Examples
|
# Examples
|
||||||
|
|
||||||
To subscribe to the Nixpkgs channel and install the GNU Hello package:
|
Subscribe to the Nixpkgs channel and run `hello` from the GNU Hello package:
|
||||||
|
|
||||||
```console
|
```console
|
||||||
$ nix-channel --add https://nixos.org/channels/nixpkgs-unstable
|
$ nix-channel --add https://nixos.org/channels/nixpkgs-unstable
|
||||||
|
$ nix-channel --list
|
||||||
|
nixpkgs https://nixos.org/channels/nixpkgs
|
||||||
$ nix-channel --update
|
$ nix-channel --update
|
||||||
$ nix-env --install --attr nixpkgs.hello
|
$ nix-shell -p hello --run hello
|
||||||
|
hello
|
||||||
```
|
```
|
||||||
|
|
||||||
You can revert channel updates using `--rollback`:
|
Revert channel updates using `--rollback`:
|
||||||
|
|
||||||
```console
|
```console
|
||||||
$ nix-instantiate --eval --expr '(import <nixpkgs> {}).lib.version'
|
$ nix-instantiate --eval '<nixpkgs>' --attr lib.version
|
||||||
"14.04.527.0e935f1"
|
"22.11pre296212.530a53dcbc9"
|
||||||
|
|
||||||
$ nix-channel --rollback
|
$ nix-channel --rollback
|
||||||
switching from generation 483 to 482
|
switching from generation 483 to 482
|
||||||
|
|
||||||
$ nix-instantiate --eval --expr '(import <nixpkgs> {}).lib.version'
|
$ nix-instantiate --eval '<nixpkgs>' --attr lib.version
|
||||||
"14.04.526.dbadfad"
|
"22.11pre281526.d0419badfad"
|
||||||
|
```
|
||||||
|
|
||||||
|
Remove a channel:
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ nix-channel --remove nixpkgs
|
||||||
|
$ nix-channel --list
|
||||||
```
|
```
|
||||||
|
|
|
@ -25,7 +25,7 @@ or completely new ones.)
|
||||||
|
|
||||||
You can manually download the latest version of Nixpkgs from
|
You can manually download the latest version of Nixpkgs from
|
||||||
<https://github.com/NixOS/nixpkgs>. However, it’s much more
|
<https://github.com/NixOS/nixpkgs>. However, it’s much more
|
||||||
convenient to use the Nixpkgs [*channel*](channels.md), since it makes
|
convenient to use the Nixpkgs [*channel*](../command-ref/nix-channel.md), since it makes
|
||||||
it easy to stay up to date with new versions of Nixpkgs. Nixpkgs is
|
it easy to stay up to date with new versions of Nixpkgs. Nixpkgs is
|
||||||
automatically added to your list of “subscribed” channels when you
|
automatically added to your list of “subscribed” channels when you
|
||||||
install Nix. If this is not the case for some reason, you can add it
|
install Nix. If this is not the case for some reason, you can add it
|
||||||
|
|
|
@ -1,50 +0,0 @@
|
||||||
# Channels
|
|
||||||
|
|
||||||
If you want to stay up to date with a set of packages, it’s not very
|
|
||||||
convenient to manually download the latest set of Nix expressions for
|
|
||||||
those packages and upgrade using `nix-env`. Fortunately, there’s a
|
|
||||||
better way: *Nix channels*.
|
|
||||||
|
|
||||||
A Nix channel is just a URL that points to a place that contains a set
|
|
||||||
of Nix expressions and a manifest. Using the command
|
|
||||||
[`nix-channel`](../command-ref/nix-channel.md) you can automatically
|
|
||||||
stay up to date with whatever is available at that URL.
|
|
||||||
|
|
||||||
To see the list of official NixOS channels, visit
|
|
||||||
<https://nixos.org/channels>.
|
|
||||||
|
|
||||||
You can “subscribe” to a channel using `nix-channel --add`, e.g.,
|
|
||||||
|
|
||||||
```console
|
|
||||||
$ nix-channel --add https://nixos.org/channels/nixpkgs-unstable
|
|
||||||
```
|
|
||||||
|
|
||||||
subscribes you to a channel that always contains that latest version of
|
|
||||||
the Nix Packages collection. (Subscribing really just means that the URL
|
|
||||||
is added to the file `~/.nix-channels`, where it is read by subsequent
|
|
||||||
calls to `nix-channel
|
|
||||||
--update`.) You can “unsubscribe” using `nix-channel
|
|
||||||
--remove`:
|
|
||||||
|
|
||||||
```console
|
|
||||||
$ nix-channel --remove nixpkgs
|
|
||||||
```
|
|
||||||
|
|
||||||
To obtain the latest Nix expressions available in a channel, do
|
|
||||||
|
|
||||||
```console
|
|
||||||
$ nix-channel --update
|
|
||||||
```
|
|
||||||
|
|
||||||
This downloads and unpacks the Nix expressions in every channel
|
|
||||||
(downloaded from `url/nixexprs.tar.bz2`). It also makes the union of
|
|
||||||
each channel’s Nix expressions available by default to `nix-env`
|
|
||||||
operations (via the symlink `~/.nix-defexpr/channels`). Consequently,
|
|
||||||
you can then say
|
|
||||||
|
|
||||||
```console
|
|
||||||
$ nix-env --upgrade
|
|
||||||
```
|
|
||||||
|
|
||||||
to upgrade all packages in your profile to the latest versions available
|
|
||||||
in the subscribed channels.
|
|
Loading…
Reference in a new issue