How to add Cockpit UI for virtual machines to NixOS
Introduction
Cockpit is a cutting-edge web-based graphical interface for server management. It allows you to administer servers effortlessly and includes a built-in terminal.
Personally, I utilize the NixOS package to monitor system logs, network settings, services, system resources, and CPU load and all without needing to touch the command line.
With the Cockpit UI for virtual machines, you can create, run, and manage virtual machines directly in your browser. Since Cockpit runs within NixOS, I thought it would be interesting to test its virtual machines UI. My aim was to replace Proxmox with NixOS, and then it would be useful to be able to create virtual machines. However, I eventually paused my testing and decided to further explore Quickemu along with Quickgui.
How To
Unfortunately, Cockpit machines is not available as a package. However there was an outdated package within the Nix User Repository (NUR), so I decided to add a custom package declaratively.
-
First create the
packages/cockpit
directoryRun the following command:
-
Create
/etc/nixos/packages/cockpit/default.nix
You can add
podman-containers.nix
in the same way, but we will ignore that for now. -
Create
/etc/nixos/packages/cockpit/virtual-machines.nix
The above is inspired by this script. Adjust the version if necessary.
-
Add the
cockpit-apps
toconfiguration.nix
According to some sources it may be necessary to add
libvirtd
orqemu-libvirtd
to the user’sextraGroups
, but I have not tested that further. -
Switch NixOS configuration
Now you can switch to the new NixOS configuration. Run the following command:
-
Check the results
Now you can browse to Cockpit and the virtual machines UI by opening a web browser and going to:
http://localhost:9090
. Replace localhost with the relevant IP address or FQDN if needed, and adjust the port if you changed it earlier.
No comments found for this note.
Join the discussion for this note on Github. Comments appear on this page instantly.