NixOS - Add Unstable Channel Packages to Configuration


Some packages are lagging behind within the default channel of NixOS. Then it is nice to have the option to use a newer package from the unstable channel.

Below is an excellent solution describing how to add the unstable channel declaratively to the configuration. For example, I used this solution for Cockpit.

Configuration

Open configuration.nix:

sudo nano /etc/nixos/configuration.nix

Adjust the configuration like this:

{ config, pkgs, ... }:

let
# add unstable channel declaratively
  unstableTarball =
    fetchTarball
      https://github.com/NixOS/nixpkgs/archive/nixos-unstable.tar.gz;
in
{
  imports =
  [ # include the results of the hardware scan.
    ./hardware-configuration.nix
  ];

  nixpkgs.config = {
    packageOverrides = pkgs: {
      unstable = import unstableTarball {
        config = config.nixpkgs.config;
      };
    };
  };

  # use unstable if you want to use the package from the unstable channel
  environment.systemPackages = with pkgs; [
     wget
     htop
     curl
     # examples from the unstable channel
     unstable.cockpit
     unstable.quickemu
     unstable.quickgui
  ];

  # Add the rest of the configuration here

}

Save the changes to configuration.nix.

Now you can switch to the new configuration:

sudo nix-collect-garbage # optional: clean up
sudo nixos-rebuild switch

You can view my complete configuration.nix here.


Read other notes

Comments

    No comments found for this note.

    Join the discussion for this note on this ticket. Comments appear on this page instantly.

    Tags


    Notes mentioning this note

    • NixOS - Cockpit Setup
      Cockpit is a modern web-based graphical interface for servers. You can use it to administer servers and it has a...

    Notes Graph