Steps to install the Nix package manager inside an Ubuntu 20.04 LXD container using the images:ubuntu/focal image:
- On the LXD host, create an Ubuntu 20.04 container:
lxc init images:ubuntu/focal container1
- On the LXD host, enable nested security on the container:
lxc config set container1 security.nesting true
- Start the container:
lxc start container1
- Inside the container, install packages curl, gnupg2, man, rsync, and xz-utils:
lxc exec container1 -- apt install --yes curl gnupg2 man-db rsync xz-utils
- Inside the container, install Nix as user ubuntu because root may not perform a single-user Nix installation:
lxc exec $container -- sudo --user ubuntu --login sh -c "curl --location --silent https://nixos.org/nix/install | sh"