How to add unstable channel packages and services to NixOS configuration
Introduction
In the default channel of NixOS, some packages tend to lag behind. Fortunately, it’s possible to use newer packages from the unstable channel when needed.
Here’s a fantastic solution for adding the unstable channel declaratively to the configuration. I’ve applied this solution for the Cockpit setup.
Additionally, I’ve detailed how to use the unstable channel for services. This approach allows you to leverage options exclusive to the unstable channel. For instance, I’ve utilized this method for the Ollama service.
How To
Unstable channel packages and services configuration
Below is the NixOS configuration for using packages from the unstable channel. The grey-highlighted sections indicate what is needed to use services from the unstable channel.
# To edit use your text editor application, for example Nano { config, pkgs, ... }:
let # Add the unstable channel declaratively unstableTarball = fetchTarball https://github.com/NixOS/nixpkgs/archive/nixos-unstable.tar.gz; in { disabledModules = [ "services/misc/ollama.nix" ]; # Disable the stable channel version # You can find the path to the service and nix file here: https://github.com/NixOS/nixpkgs/tree/656a024f9187fcfc8e5ca81a9c3f370af52e0776/nixos/modules/services
imports = [ ./hardware-configuration.nix # Include the results of the hardware scan (unstableTarball + "/nixos/modules/services/misc/ollama.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 service with options from the unstable channel services = { ollama = { enable = true; acceleration = "cuda"; # Or rocm package = pkgs.unstable.ollama; # Also use the package from the unstable channel! }; };
# Add the rest of the configuration here }
Switch NixOS configuration
To apply the new NixOS configuration, run the following command:
# Open your terminal applicationsudo nix-collect-garbage # Optional: clean upsudo nixos-rebuild switch
No comments found for this note.
Join the discussion for this note on Github. Comments appear on this page instantly.