NixOS - Rebuild Switch results in Errors

Hi,

I trying to install NixOS containers. My operating system is NixOS.

When I created a new container with incus. I tried with nixos/24.11 and nixos/unstable.

I did the following:

incus exec nixos bash

[root@nixos:~]# nixos-rebuild switch

I get these errors:

warning: Nix search path entry '/nix/var/nix/profiles/per-user/root/channels/nixos' does not exist, ignoring
warning: Nix search path entry '/nix/var/nix/profiles/per-user/root/channels' does not exist, ignoring
error: file 'nixpkgs/nixos' was not found in the Nix search path (add it using $NIX_PATH or -I)

I also tried:

nixos-generate-config --root /mnt
nixos-install

I get the same errors.

Am I missing something to setup Nixos ?

Someone suggested this and it worked:

incus launch images:nixos/unstable nixos -c security.nesting=true

1 Like

Welcome!

The NixOS documentation on Incus does not mention the requirement for the Incus security.nesting flag. You would need to use this flag if the host is not a baremetal system or a virtual machine, but a container. Can you verify that the host is not a container, and that you have followed the steps for NixOS at How to install Incus - Incus documentation ?

Thanks for your reply Simos

Actually, it does mention it for NixOS Instances

To launch a new NixOS container use the following command.

incus launch images:nixos/unstable nixos -c security.nesting=true

My setup is:

Mac Mini running NixOS → Incus → NixOS container

It’s the nixos container’s configuration I wasn’t able to modify the or rebuild.

When it says NixOS Instances, it means that you are running NixOS in Incus and you want to launch a new instance in there. Either in a container, either in a virtual machine. In the former you enable nested namespaces, in the latter you disable Secure Boot because the NixOS kernel does not have a SecureBoot key.