Search code examples
nixnixos

NixOS: Setting the default channel in configuration.nix


How do I set the default channel in NixOS's /etc/configuration.nix?

There is a command to set it and rebuild with

sudo nix-channel --add https://nixos.org/channels/nixpkgs-unstable
sudo nixos-rebuild switch -I nixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixpkgs

but I'd like to have it setup in configuration.nix so I don't have to remember how to do this everytime. Thanks!


Solution

  • system.autoUpgrade.channel is what you might be looking for

    set it to any channel e.g.

    system.autoUpgrade.channel = "https://nixos.org/channels/nixos-16.03-small/";

    the documentation says:

    by default, this is the channel set using nix-channel (run nix-channel --list to see the current value)

    an up to date list of channels can be found on https://nixos.org/channels/

    ref: https://nixos.org/nixos/manual/options.html#opt-system.autoUpgrade.channel https://nixos.org/nixos/manual/index.html#idm140737317454064