NixOS: setting the default channel in the configuration.nix file

How to set default channel in NixOS /etc/configuration.nix ?

There is a team to install it and rebuild using

 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 would like to configure it in the configuration.nix file, so I don’t need to remember how to do it every time. Thanks!

+5
source share
3 answers

Set nixPath = [ "nixpkgs=http://nixos.org/channels/nixos-unstable/nixexprs.tar.xz" ]; , see https://github.com/snabblab/snabblab-nixos/blob/master/modules/common.nix#L37

+3
source

The nix.nixPath ( ref ) parameter looks like it will do what you need.

Also the nixos-unstable channel may be more suitable for you, rather than nixpkgs-unstable. I believe that pkgs in the nixpkgs channel are tested and built for systems other than nixOS, although I can’t remember the link for this at the moment.

 nix-channel --add https://nixos.org/channels/nixos-unstable/ nix-channel --update nixos-unstable 
 # /etc/nixos/configuration.nix # Put nixos-unstable at the front of nixPath nix.nixPath = pkgs.lib.mkBefore [ "nix/var/nix/profiles/per-user/root/channels/nixos-unstable" ]; 

If you need real nix-channel commands in your configuration.nix file, you can write a little systemd service for this, as shown here .

PS I realized that you can just point the nixos path to a nixos-unstable channel by running nix-channel --add https://nixos.org/channels/nixos-unstable/ nixos , but I think the first solution is clearer.

+2
source

system.autoUpgrade.channel is what you can look for

install it on any channel, for example.

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

The documentation says:

the default is a set of channels using nix-channel (run nix-channel --list to see the current value)

An updated list of channels can be found at https://nixos.org/channels/

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

+2
source

Source: https://habr.com/ru/post/1246555/


All Articles