The nix.nixPath
(ref) option looks like it will do what you're after.
Also the nixos-unstable channel might be more appropriate for you, rather than nixpkgs-unstable. I believe the pkgs in the nixpkgs channel are tested and built for non-nixOS systems, though I can't remember a reference for that 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
{ lib, ... }:
{
nix.nixPath = lib.mkDefault (lib.mkBefore [ "nixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixos-unstable" ]);
}
If you want the imperative nix-channel commands in your configuration.nix as well you could write a small systemd service to do so, as shown here.
Edit: To ensure configuration.nix
is built from the latest unstable
channel just set the value of nixpkgs
as in the answer from @iElectric and Nix will use the expressions contained at that URL whenever it evaluates configuration.nix
.
PS I realised you could also just point the nixos path to the nixos-unstable channel by doing nix-channel --add https://nixos.org/channels/nixos-unstable/ nixos
but I think the first solution is clearer.