NixOS in LXD VM

I would like to try NixOS inside an LXD VM. How should I proceed? I assume I need to create a new VM first:

lxc init my_nix --vm --empty

I can also download the NixOS Graphical ISO image https://nixos.org/download/#nixos-iso. Do I need to re-pack the NixOS ISO first, before I insert the ISO disk into the VM?

lxd-imagebuilder repack-nixos # does that option exist??

Thank you.

NixOS is available on the image server https://images.lxd.canonical.com

You can simply create an instance like so:

lxc launch images:nixos/25.05 --vm nix

–vm is optional, you can also choose to create a LXC.

Obtain a shell:

lxc exec nix -- /bin/sh

note: If you wish to create a LXC instead, its mandatory to configure security.nesting=true

2 Likes

Thank you. Would this give me a graphical desktop? Will certainly try out your suggestion in any case.

The steps I provided give you a shell prompt inside your nixOS instance. You would have to enable the graphical desktop functionality yourself. If you do, you can easily access it through the LXD UI.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.