Oh, interesting point. I forgot that doing a separate import would not include allowUnfree. But right now I have Terraform installed without providing that in config and it still works. So not sure if that’s necessary.
You have added the channel as your user, though you rebuild the system as root, you should add the unstable channel to your roots environment using sudo nix-channel --add https://nixos.org/channels/nixos-unstable nixos-unstable.
Also, to avoid warnings about that channel name beeing used twice, you should remove it from your user.
Indeed, I was just confused by the fact that it worked with passing in the users environment.
Have you run sudo nix-channel --update after adding the channel?
The channel isn’t available without it…
By running sudo -i nixos-rebuild switch --upgrade (which implies a nix-channel --update) you might even have caused that nix updated and created the channels in your users environment.
Yeah. It’s weird. But what’s even weirder is that I did nix-channel --update without sudo and now sudo nixos-rebuild switch --upgrade works without the -i.
I really don’t get how that nix-channel --update fixed anything since as you can see in my OP the channel symlinks were clearly visible in the /home/jakubgs/.nix-defexpr/channels folder.
They are within your users folder, which nixos-rebuildshould not respect, but you forced it to, by using sudo -i. That together with the implied update of the channels probably confused the system.