Skip to content

Declarative libvirt (and NixOS VMs) for NixOS

Notifications You must be signed in to change notification settings

yuv418/launchnix

Repository files navigation

Launchnix

A clone of NixOps (ONLY for libvirt) that won’t be buggy and outdated (hopefully).

LaunchNix is a WIP project, but it does work. I use it on my servers.

Launchnix will utilize `morph` behind-the-scenes after automatically creating virtual machines for you.

NOTE: I’m not very good with Nix/NixOS yet (or Rust, but I’m slightly more experience with Rust than I am with NixOS). The implementation of things in Launchnix will probably not be very good.

Installation

In `environment.systemPackages` in your `configuration.nix`, add

environment.systemPackages = with pkgs; [
    # Other things
    (import "${(builtins.fetchTarball "https://github.com/cdknight/launchnix/archive/master.tar.gz")}" {}).launchnix
];

Implementation Checklist/Roadmap

This is a list of semi-detailed steps that need to be done for the project to be functional.

  • [X] Build NixOS images
  • [X] Copy NixOS image to user-defined libvirt storage pool
  • [X] Upload user-defined ssh keys and unset root passwords (This was implemented differently but it works)
  • [X] Load deployment into morph and deploy
  • [X] Detect changes in the libvirt configuration (state file?). If there are changes, shut down the domain, redefine the XML, and redeploy libvirt.
  • [X] Static IPs
  • [ ] Integration with sudo nixos-rebuild switch
  • [ ] Honor SSH key preferences in deployment file
  • [X] Command/command helpers
    • [X] Reboot
    • [X] Shutdown
    • [X] SSH
  • [-] Non-NixOS guests/helpful additions
    • [X] installationMedia field (path to ISO file; you could use builtins.fetchUrl)
      installationMedia = builtins.fetchurl "https://dl-cdn.alpinelinux.org/alpine/v3.13/releases/x86_64/alpine-standard-3.13.5-x86_64.iso";
              
    • [-] initialDisks field: might look like this Only boot disk implemented
      initialDisks = {
          boot = {
              size = 40000; # In MB
              extraXML = ''
                  <!--extra xml here-->
              '';
              fromBackup = "/path/to/backup-file.here" # only installationMedia *or* fromBackup will be allowed at the same time for the boot disk.
          };
          games = {
              physicalDisk = "/dev/sdd";
          };
      }
              
    • [ ] vGPUType field: for NVIDIA vGPUs (specify mdev type). Also will work for NixOS guests
      vGPUType = "nvidia-288"
              
    • [ ] pciDevices field: for PCI devices. Also will work for NixOS guests
      pciDevices = [ {
        id = "09:00.0";
        gpu = true;
        romFile = "path-to-romfile.rom";
        extraXML = ''
        <!--extra xml-->
        '';
      }];
              
    • [ ] bootOrder field: for setting the boot order of VMs
      bootOrder = ["PXE" "games" "boot"] # TODO enums
              
  • [ ] launchnixd and LaunchnixOS
    • Lofty goal: make launchnix an operating system/full-fledged virtualisation platform
    • After non-NixOS guest support
    • [ ] Remove the libvirt dependency (or better, make multiple backends)—use QEMU+QMP with UNIX sockets
      • May sound like NIH syndrome, but if we’re writing our own daemon it should be to replace libvirt
    • [ ] Write a git server/use a preconfigured one to manage repos (PaaS/Heroku-like)
      • [ ] On push, update all the virtual machines
      • [ ] Support multiple repos: each folder in a monorepo and separate repos
      • [ ] Control verbs over HTTP (guest migration, etc.)
      • [ ] Authentication

About

Declarative libvirt (and NixOS VMs) for NixOS

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published