XCP-ng
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    NiXOA: A declarative implementation of Xen Orchestra using flakes on NixOS

    Scheduled Pinned Locked Moved Infrastructure as Code
    nixos
    4 Posts 2 Posters 301 Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • dalemD Offline
      dalem Pro Support Team
      last edited by dalem

      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:

      https://codeberg.org/NiXOA

      A dalemD 2 Replies Last reply Reply Quote 2
      • A Offline
        afk @dalem
        last edited by

        @dalem That looks awesome ! Glad to see nix/nixos getting more and more adoption.

        It must have been a pain to build the pkgs, thanks a lot for working on this. I'll give it a try when I manage to free some time.

        Have you considered upstreaming the module/pkgs to nixpkgs or is this too much work ? I have not contributed there yet so I don't know if it would get merged as is.

        dalemD 1 Reply Last reply Reply Quote 0
        • dalemD Offline
          dalem Pro Support Team @afk
          last edited by

          @afk Great question! I’ve decided the best path forward is to create some GitHub mirrors and then submit the libvhdi package upstream, wait for that to get approved, and then submit the Xen-orchestra-ce package since it’s dependent on libvhdi, it’ll take a while but having them both as upstream nix packages is the goal

          1 Reply Last reply Reply Quote 0
          • dalemD Offline
            dalem Pro Support Team @dalem
            last edited by

            Version 1.4.0 is released: https://codeberg.org/NiXOA/system/releases/tag/v1.4.0

            It includes significant changes and improvements, including: dedicated getting started section, migration to valkey, only needing to clone system, and helper scripts.

            the xen-orchestra-ce nixpkg now references the libvhdi nixpkg, and the core flake now references and pulls from the xen-orchestra-ce repo as an overlay. System (the user input flake) now uses the Core repo as an overlay, reducing the need to clone both locally AND allowing system to pull new updates and releases from core. XO, and libvhdi as needed.

            The next goal is:
            Make an xsconsole-like TUI
            Automate package updates for libvhdi and xen-orchestra-ce using CI/CD pipelines
            Submit libvhdi and xen-orchestra-ce as official nixpkgs

            1 Reply Last reply Reply Quote 0
            • First post
              Last post