installing NixOS on KVM - QEMU
https://wiki.archlinux.org/title/QEMU
There were some issue when installing NixOS on VirtualBox:
- small resolution
- cannot start hyprland
One thread suggested to use KVM instead.
So here I am…
CLI
Tip
It’s better to use
virt-manager
as it’s more user-friendly and will add the corresponding flags.
Installation
Tip
When I tried to launch the installation, I had a “Kernel panic” error with the message “is deadlock on memory”. By default only 128 MiB of memory is assigned to the machine. The amount of memory can be adjusted with the -m switch, for example -m 512M or -m 2G.
Issue encountered
Cannot start SSH daemon ✅
I installed NixOS using the following commands:
I had the following error:
[ERROR] Cannot start ssh daemon
I changed the command from -boot order=d
to -boot menu=on
.
However, now, it’s a black screen…
Success
I tried another guide: https://www.baeldung.com/linux/qemu-from-terminal
Stuck on loading screen ✅
I used another command to support UEFI. It started good, i.e. the resolution was greater than the previous one (3/4 of my screen), however, the screen is stuck to the loading screen with the TianoCore and Nix logos…
Success
Used the guide from above https://www.baeldung.com/linux/qemu-from-terminal, and it worked.
Small resolution ✅
Success
See https://superuser.com/a/169243. I needed to add the flag
-vga std
when executing theqemu-system-x86_64
command.
Clipboard not shared ❌
Tried to add SPICE to have shared clipboard from host to guest:
Fail
I gave up. It seems it’s not possible to share the clipboard on Wayland.
virt-manager
Installation
Installation tutorial: https://fr.linux-console.net/?p=22252
Issues encountered
No GUI for Hyprland ✅
Configure the VM with 3D acceleration on by updating its configuration:
- Video → Model: Virtio
- Display Spice
- Listen Type: None
- Check OpenGL
- Select
0000:00:02:0 Intel
Network “default” is not active ✅
I installed NixOS at bioserenity office using virt-manager
.
Now, I tried to start the VM at home, but I got the error:
Error starting domain: Requested operation is not valid: network 'default' is not active
Traceback (most recent call last):
File "/usr/share/virt-manager/virtManager
...
Success
I had to enable it:
Source: https://askubuntu.com/a/1120132
Alacritty not launched on Hyprland startup ✅
When I re-started the VM at home, using Hyprland, alacritty is not executing automatically.
Moreover, when I tried to SUPER+Return
, no console is spawn…
Success
It was my
alacritty/default.nix
configuration that was not working… I had the following:And the symlink creation made some issues…
Shared clipboard ❌
The clipboard are not shared between the host and the VM.
Tried adding the following configuration at NixOS level:
then, in virt-manager
, add channels:
- qemu-vdagent
- device type: qemu-vdagent
- target type: virtio
- target name: org.qemu.guest_agent.0
- clipboard: on
- spice
- device type: spicevmc
- target type: virtio
- target name: com.redhat.spice.0
There was another channel that was present before I added my channels (its name was conflicting with the channel I wanted to add):
I followed the tips here: https://unix.stackexchange.com/questions/642562/make-shared-clipboard-work-for-qemu. However, it seems it’s only working for X11.
Fail
Could not find a way to share clipboard. Instead, I enable ssh so it’s easier to copy paste.
Cannot ssh from host to VM ✅
I enabled sshd at NixOS level:
However, it’s not connecting. Maybe I need to add my public key?
Success
I only needed to change the value of
PasswordAuthentication
totrue
. Source: https://stackoverflow.com/a/4398006