Blending in Packages from Nix's Unstable Repo
Background
I recently updated the todoist-electron package in the NixOS repository, and wanted to be able to use it, but my laptop is set on the 23.05 channel. I knew I should be able to blend stable and unstable channels but I had to research and test out how to do this on my setup.
Process
First you’ll need to add the unstable channel to your system with the nix-channel command:
sudo nix-channel --add https://nixos.org/channels/nixos-unstable nixos-unstable
Now you can specify a scoped variable to load data about the specific channel you want, for example:
{ config, pkgs, ... }:
let
unstable = import <nixos-unstable> { config = { allowUnfree = true; }; };
in {
environment.systemPackages = with pkgs; [
# snip
speedtest-cli
unstable.tailscale
zoxide
# snip
];
}
From here you can run sudo nixos-rebuild switch and it should “Just Work”.
The package variable
Some nixos packages have extra configuration options and if you use these and also specify a
package from unstable, you’ll get confusing results. I set my version of tailscale to pull from unstable
but further down in the file I specified services.tailscale.enable. This caused me to have 2 versions of
tailscale on my laptop (the client was the version in the unstable channel and the systemd package was the
23.05 version). To remedy this, many packages have a .package configuration option to be set as well as
specifying the package to be installed. So you can specify services.tailscale.package = unstable.tailscale
and now systemd will be enabled with the version you wanted (instead of the default channel’s version).