NixOS - Add Unstable Channel Packages and Services 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.
I also described how you can use the unstable channel for services. That way, for example, you could make use of options that were only available via the unstable channel. As an example, I’ll use the Ollama service.
Configuration (Unstable Channel Packages)
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
.
Configuration (Unstable Channel Packages and Services)
If you also want to be able to use services via the unstable channel, you can add the following to the configuration. The unstableTarball
is used again.
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
{
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 =
[ # include the results of the hardware scan.
./hardware-configuration.nix
(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
}
Save the changes to configuration.nix
.
Switch Configuration
Now you can switch to the new configuration:
sudo nix-collect-garbage # optional: clean up
sudo nixos-rebuild switch
Here you can find more information about updating and upgrading NixOS.
You can view my server configuration.nix
here.
Read other notes
Tags
Notes mentioning this note
- NixOS - Server Configuration and Switch to Podman
For some time now I have been looking for an interesting lightweight linux distribution that could replace Ubuntu
- NixOS - Cockpit Setup
Cockpit is a modern web-based graphical interface for servers. You can use it to administer servers and it has a...
- NixOS - Add Podman Containers UI to Cockpit
With Cockpit Podman Containers you can manage Podman containers in your browser
- NixOS - Add Virtual Machines UI to Cockpit
With Cockpit Virtual Machines you can create, run, and manage virtual machines in your browser
- NixOS - Ollama AI tool with Oterm and Open WebUI Setup
After my adventure with [[Serge LLaMA AI Chat - Windows Podman Container Setup|Serge AI Chat]] it was time to take...
- NixOS - Guacamole Clientless Remote Desktop Gateway Setup
Once Guacamole is installed on a machine, in my case running NixOS, all you need to access your desktop environment...
Comments
No comments found for this note.
Join the discussion for this note on this ticket. Comments appear on this page instantly.