How to set up and enter an Ubuntu chroot inside Nixos?

I’m using NixOS and I’m trying to set up an Ubuntu chroot.

Following non-NixOS-specific instructions that I have found around the internet, I have managed to do the following:

sudo mkdir -p /chroot/ubuntu-1804
sudo debootstrap bionic /chroot/ubuntu-1804 http://archive.ubuntu.com/ubuntu/

The latter command prints a lot of output and reports “Base system installed successfully.”.

Now, I would like to enter the chroot as a non-root user. This is where everyone suggests a command like schroot. The problem is, I can’t find it in Nixpkgs. Is it available to NixOS, or is there an alternative that I should use instead?

1 Like

From a quick web search it seems as if schroot is just a wrapper around mount to bind mount some patches like /proc, /sys, /dev and others and then doing an actual chroot.

Have you considered using chroot directly? Take a look at the funtoo installation guide. When I went through that process they did all the mounts manually.

Instead you can also use systemd-nspawn to actually “boot” the Debian.

1 Like

I just tried it with plain chroot and found that it works well, proc and sys are already mounted. It seems like the behaviour of chroot has changed in the meantime.

1 Like