Problem rebuilding nixos running under nspawn on wsl-2

I’m following the article:

Running NixOS from any Linux Distro in systemd-nspawn Containers (

I’m doing this using an arch linux distro running under latest wsl-2.

I hit an issue importing the tar file

machinectl pull-tar nixos --verify=no

I got the error:

Failed to transfer image: Interactive authentication required.

I worked around this by first downloading the tarball and then used “machinectl import-tar” which worked fine and I was able to set a password and login the the nixos container.

I was able to connect to the host network, run vim etc without issue.

When I tried to do a rebuild to add an nginx service I got:

nixos-rebuild switch
warning: creating lock file ‘/etc/nixos/flake.lock’
building the system configuration…
/nix/store/ line 2: ln: command not found
warning: error(s) occurred while switching to the new configuration

Though ln is available:

[root@nixos:~]# which ln

Does anyone know what the issue is or best way to debug?

Hello @mwoodpatrick,

i haven’t seen this post earlier. If you have a problem in the future, please don’t hesitate to drop a mail.

Thankfully, someone else (or was that you?) fixed this in a PR which i merged (Fix bug with missing ln binary by carbolymer · Pull Request #3 · tfc/nspawn-nixos · GitHub) and created a new release from.

I also updated the pull-tar command to point to the latest release.

I cannot reproduce the error that you got while downloading the image, but the error that you got while doing nixos-rebuild switch should be fixed now.

1 Like