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 installed
Flake Overview
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 flake
This 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.
Editing configuration.nix is 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.
While you're at it, go ahead and update hardware-configuration.nix to have a swap file (you can ignore this if you set a swap file in the NixOS installer) by adding the following lines to the config:
swapDevices = [
{
device = "/swapfile";
size = 4096; # in MB (4GB)
}
];
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 settings
You 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:
- Go to the user-config directory
- Update inputs from nixoa-vm:
nix flake update
- Add all changed files (including hardware-configuration.nix):
git add *
- Commit your changes:
git commit -m "Initial configuration"
- 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
- zoxide
- eza
- bat
- and other terminal enhancements
This 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: