NiXOA: A declarative implementation of Xen Orchestra using flakes on NixOS
-
I have created two Nix flakes for running Xen Orchestra inside a NixOS virtual machine on XCP-ng. I am a strong supporter of Nix and NixOS, and I was interested in the idea of building Xen Orchestra from source in a fully declarative way.
Requirements
Before you begin, you need:
• A virtual machine running NixOS
• Flakes enabled (either in your system configuration or in your current shell)
• The git package installedOverview of the Flakes
There are two flakes:
- nixoa-vm
This is the main flake of the project. It includes:
• A Xen Orchestra package built from source
• A libvhdi Nix module
• Update and maintenance modules
• System and user configuration modules
• Xen guest tools (via xen-guest-agent)
• Support for a separate user-config flakeThis flake is where the Xen Orchestra service and core functions are defined. It is not intended to be user editable when using it.
- user-config
This flake contains your machine-specific settings.
• configuration.nix
Used for basic system settings such as:
• Hostname
• Username
• Time zone
• SSH keys
• hardware-configuration.nix
You must copy this file from /etc/nixos/hardware-configuration.nix into the root of the user-config directory.Making Customizations
There are helper scripts to simplify setup. In the future, these may be replaced with a text-based user interface (TUI).
In most cases, you will only need to edit:
• configuration.nix – system-level settings
• home.nix (optional) – if you want more control using Home Manager
• config.nixoa.toml – only if you have custom Xen Orchestra server settingsYou usually do not need to edit config.nixoa.toml. If you do, avoid changing the Redis, sudo, or HTTPS mount settings unless you know exactly what you are doing, as this can break the system.
Building the System
After you finish editing your configuration:
1. Go to the user-config directory
2. Update inputs from nixoa-vm:nix flake update
3. Add all changed files (including hardware-configuration.nix):git add *
4. Commit your changes:git commit -m "Initial configuration"
5. Rebuild the system:sudo nixos-rebuild switch --flake .#nixoa
(Replace nixoa if you changed the hostname.)
Installer
The documentation mentions an installer that automates most of these steps. It exists, but it still needs more testing and should be considered experimental.
Optional Shell Enhancements
If you change the shell for the xoa user from bash to zsh in configuration.nix, the system will automatically install several quality-of-life tools, including:
• oh-my-posh
• fzf
• eza
• bat
• and other terminal enhancementsThis is a personal passion project that I built on my own. If you are interested, please take a look and share any feedback or suggestions: