Virtualisation
Table of Contents
1. Preface
It's completely insane to me how good it works - a config file and a single command get you a working qemu vm.
2. QEMU
2.1. Readup
- tweag on VM's - has all the commands you could ever want.
- nixpkgs/nixos/lib - got some fun stuff.
2.2. Example
Using this stuff to try out xmonad. Haskell configuration seems really promising, and WM seem like a perfect candidate for VM testing.
2.3. Usage
To build a VM from ./config.nix run:
nix-build '<nixpkgs/nixos>' -A vm -I nixos-config=./config.nix
This builds vm attrib from nixos subdir of nixpkgs with nixos-config path swapped for ./config.nix. Nixpkgs is pretty complicated so I haven't traced where this attribute is defined, but hope to soon.
This file seems to be what's evaluated through the command above.
2.4. Applications
The VM is pretty slow, which I hope to look into fixing once I find actuall documentation on the issue. Same goes for network access, it doesn't seem to be accessible from the host by default.
On speed - that's seems to be a QEMU issue, so might read this. On network - read the source.
Apart from that, you can run subservices with this thing, but that doesn't seem practical. I hope to use it for testing configurations once the stuff above is figured out. Ideally it should be possible to
deploy a whole cluster of virtual machines and see how they interract with something like wireshark.
It's possible to run integration tests with VM's, but I don't know the exact mechanics of this process. This seems to be what I actually want.
3. nixos-container
Flakes come with a really nice toolset! Out of the box lightweight containers is pretty cool idk.