Nix channels seem to be broken in nixos Incus container

I’ve been unable to rebuild the system in a nixos Incus container. nixos-rebuild switch fails with a bunch of errors, the most relevant of which appears to be error: file 'nixpkgs/nixos' was not found in the Nix search path (add it using $NIX_PATH or -I). In response to this I found the advice to add and update a channel, however nix-channel --update fails with the following errors:

error: this system does not support the kernel namespaces that are required for sandboxing; use '--no-sandbox' to disable sandboxing
error: program '/nix/store/x92x70hdpnpdblgnvpyar7nbvp8h74nb-nix-2.28.5/bin/nix-env' failed with exit code 1

running nix-channel --no-sandbox --update fails with identical output.

nix --version:

nix (Nix) 2.28.5

output of nix-channel --list:

nixos https://nixos.org/channels/nixos-25.05
nixpkgs https://nixos.org/channels/nixos-25.05

value of NIX_PATH:

nixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixos:nixos-config=/etc/nixos/configuration.nix:/nix/var/nix/profiles/per-user/root/channels

Note: /nix/var/nix/profiles/per-user/root/ is an empty directory (does not contain channels)

~/.nix-channels contains:

https://nixos.org/channels/nixos-25.05 nixos
https://nixos.org/channels/nixos-25.05 nixpkgs

and ~/.nix-defexpr contains channels, a symlink to /nix/var/nix/profiles/per-user/root/channels which doesn’t exist.

The host OS is Arch in case that matters.

To create the container and hit the error:

[admin@host ~]$ incus launch images:nixos/25.05 nixos
Launching nixos
[admin@host ~]$ incus shell nixos

[root@nixos:~]# nixos-rebuild switch
output of `nixos-rebuild switch` when run for the first time
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:
       … while calling the 'import' builtin
         at «string»:1:6:
            1| with import <nixpkgs/nixos> {}; config.system.build.nixos-rebuild
             |      ^

       … while realising the context of a path

       … while calling the 'findFile' builtin
         at «string»:1:13:
            1| with import <nixpkgs/nixos> {}; config.system.build.nixos-rebuild
             |             ^

       error: file 'nixpkgs/nixos' was not found in the Nix search path (add it using $NIX_PATH or -I)
building Nix...
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)
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' was not found in the Nix search path (add it using $NIX_PATH or -I)
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/modules/installer/tools/nix-fallback-paths.nix' was not found in the Nix search path (add it using $NIX_PATH or -I)
these 61 paths will be fetched (23.84 MiB download, 97.49 MiB unpacked):
# . . . snip . . .
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' was not found in the Nix search path (add it using $NIX_PATH or -I)
building the system configuration...
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)
output after adding the channel and attempting to update it
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:
       … while calling the 'import' builtin
         at «string»:1:6:
            1| with import <nixpkgs/nixos> {}; config.system.build.nixos-rebuild
             |      ^

       … while realising the context of a path

       … while calling the 'findFile' builtin
         at «string»:1:13:
            1| with import <nixpkgs/nixos> {}; config.system.build.nixos-rebuild
             |             ^

       error: file 'nixpkgs/nixos' was not found in the Nix search path (add it using $NIX_PATH or -I)
building Nix...
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)
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' was not found in the Nix search path (add it using $NIX_PATH or -I)
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/modules/installer/tools/nix-fallback-paths.nix' was not found in the Nix search path (add it using $NIX_PATH or -I)
/tmp/nixos-rebuild.RCSoYB/nix
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' was not found in the Nix search path (add it using $NIX_PATH or -I)
building the system configuration...
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)

Recreating the container with --config security.nesting=true allows nixos-rebuild switch to succeed.

1 Like