AshleyYakeley / NixVirt

LibVirt domain management for Nix
MIT License
192 stars 21 forks source link

Feature Request: Flake Parts Module #67

Open antholeole opened 1 month ago

antholeole commented 1 month ago

would it be possible to make this into a flake parts module? I'm running a non-nixos system. I'd like my VM configuration to not be tied to my HM config - rather, the project that uses the VM itself. Thanks!

flake parts: https://flake.parts/

That being said its non-blocking... for other flake-parts users, here's a starting flake part:

{inputs, ...}: {
  perSystem = {
    pkgs,
    system,
    ...
  }:
    with inputs.nixvirt.lib; let
      nixvirt = inputs.nixvirt.lib;
      domain = nixvirt.domain;

      linux-domain = domain.writeXML (domain.templates.linux {
        name = "Penguin";
        uuid = "cc7439ed-36af-4696-a6f2-1f0c4474d87e";
        memory = {
          count = 6;
          unit = "GiB";
        };
        storage_vol = {
          pool = "MyPool";
          volume = "Penguin.qcow2";
        };
      });
    in {
      packages.runvirt = let
        virtdeclare = inputs.nixvirt.apps.${system}.virtdeclare;
      in
        with virtdeclare;
          pkgs.writeShellScriptBin "runvirt" ''
            ${program} --define ${linux-domain} $@
          '';
    };
}

thanks for the excellent package!