NixOS: Difference between revisions

imported>Ixxie
No edit summary
imported>HLandau
No edit summary
Line 94: Line 94:
=== Imperative Operations ===
=== Imperative Operations ===


====  User Environment Management ====
====  User Environments ====


In addition to declarative system configuration, NixOS offers imperative commands to manage ''user specific'' package management. These operations are managed by the <code>nix-env</code> command line tool. The following is a summary of some common operations that can be performed with it:
In addition to declarative system configuration, NixOS offers the imperative <code>nix-env</code> command which can be used to install packages at the user level. Packages installed using <code>nix-env</code> are only available to the given user, and do not change system state.


''Common <code>nix-env</code> Commands:''
{|  class="wikitable"
{|  class="wikitable"
|+ Common <code>nix-env</code> Commands
|-
|Searching for packages
|Searching for packages
|<code>nix-env -qaP '.*packagename.*'</code>
|<code>nix-env -qaP '.*packagename.*'</code>
Line 118: Line 119:
==== Channels ====
==== Channels ====


Nix ''channels'' are mechanisms for distributing Nix expressions alongside the associated binaries for them. Official Nix channels are automatically updated once a certain tests are passed in Nixpkgs' Hydra instance. It is also possible to create one's own Nix channels, but here we focus the official channels. A full list of the available official channels is available at [https://nixos.org/channels/ https://nixos.org/channels/], but they can be classified into three main types.
Nix ''channels'' are mechanisms for distributing Nix expressions as well as the associated binaries for them; a Nix channel corresponds to a repository in a conventional package management system. Official Nix channels are automatically updated once tests are passed in Nixpkgs' [[Hydra]] instance. It is also possible to create one's own Nix channels, but here we focus the official channels. [https://nixos.org/channels/ A full list of the available official channels is available].


''Channel Types:''
NixOS is distributed through a number of channels. These NixOS channels can be broadly categorised into ''stable'' and ''unstable'' channels, and ''large'' and ''small'' channels:
{|  class="wikitable"
 
|Stable
* Stable/unstable:
|''nixos-17.09''
** Stable channels (<code>nixos-17.09</code>) provide conservative updates for fixing bugs and security vulnerabilities, but do not receive major updates after initial release. New stable channels are released every six months.
|These receive conservative updates for fixing bugs and security vulnerabilities.
** Unstable channels (<code>nixos-unstable</code>, <code>nixos-unstable-small</code>) correspond to the main development branch of Nixpkgs, delivering the latest tested updates on a rolling basis.
|-
* Large/small:
|Unstable
** Large channels (<code>nixos-17.09</code>, <code>nixos-unstable</code>) provide binary builds for the full breadth of Nixpkgs.
|''nixos-unstable''
** Small channels (<code>nixos-17.09-small</code>, <code>nixos-unstable-small</code>) are identical to large channels, but contain fewer binaries. This means they update faster, but require more to be built from source.
| Corresponds to the main development branch of Nixpkgs, delivering the latest tested updates.
 
|-
Most users will want the stable/large channel, currently <code>nixos-17.09</code>.
|Small
|''nixos-17.09-small'', ''nixos-unstable-small''
| Identical to their normal namesakes, but containing fewer binaries. This means they update faster but require more to be built from source.
|}


NixOS will use the root's channels to update the system wide configuration, and user-specific channels to manage the user environment; this means that you must <code>sudo</code> commands intended to manage the channel your <code>configuration.nix</code> should use. The following are common commands to manage channels on NixOS:
Like packages installed via <code>nix-env</code>, channels are managed at user-level. NixOS uses the channels set for the <code>root</code> user to update the system-wide configuration; channels set for other users control only the user environment for that user. If you wish to change the channel used by the system-level configuration (<code>/etc/nixos/configuration.nix</code>), ensure you run the correct <code>nix-channel</code> command as root:


{| class="wikitable"
{| class="wikitable"
|+ Common nix-channel commands
|-
|Listing current channels
|Listing current channels
|<code>nix-channel --list</code>
|<code>nix-channel --list</code>
Line 157: Line 156:
|}
|}


Note that after updating channels, one still has to rebuild with <code>nixos-rebuild switch</code>, but one can also run <code>nixos-rebuild switch --upgrade</code> to update channels and rebuild.
Note that updating channels won't cause a rebuild in itself; if you want to update channels and rebuild, you can run <code>nixos rebuild --upgrade</code> to do both in one step.


== Internals ==
== Internals ==