Chris Stryczynski

Software Developer / Consultant

A quick introduction to Nix packages, channels and Nixos generations

Posted on: 20/02/2020

I remember being incredibly excited to try out Nix. But I initially had a lot of confusion over packages/channels/generations - hence this post!

A channel refers to a git branch in this repo: https://github.com/NixOS/nixpkgs-channels

Note: all these commands could be user specific, hence if you run them as root / sudo you may get different results.

You can view your existing channels with:

sudo nix-channel --list
nixos https://nixos.org/channels/nixos-19.09
unstable https://nixos.org/channels/nixpkgs-unstable

You can “pull” the latest commits into your channels with

sudo nix-channel --update

If you create a new generation, it will reference the commits that exist in your local definition of the channel.

sudo nixos-rebuild build

Generations!

Your regular “user” (or even root!) has a nix environment separate from your Nixos “system” environment (also a nix environment).

To list the generations of your system:

nix-env --list-generations --profile /nix/var/nix/profiles/system

To list the generations of your user:

nix-env --list-generations
Comments

No comments, yet!

Submit a comment