How to change the default channel when building my own NixOS CD?

I managed to build my own custom NixOS ISO with this command:

nix-build '<nixpkgs/nixos>' \
  -A \
  -I nixpkgs=channel:nixos-19.09-small \
  -I nixos-config=iso.nix

where iso.nix is my custom configuration.
The ISO is build with the nixos-19.09-small channel thanks to the -I nixpkgs=… option.

However, when I install a new machine with this ISO and I run nix-channel --list from it, I get:


Is there a way to change the default channel that root is subscribed to? In my case, I would like the default channel to be nixos-19.09-small.

Possibly to do with system.defaultChannel (as seen from <nixpkgs/nixos/modules/services/misc/nix-daemon.nix>, from grepping .nix-channels)?

1 Like

Yes, system.defaultChannel is the option that solves this.

It took me some time because you can set the option for the installer and/or the systems installed by the installer (when combining with system.nixos-generate-config.configuration).

Thank you