From eb287f9850ee412b46ef223e09980e42f114442c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20B=C3=A4dorf?= Date: Mon, 17 Oct 2022 15:58:03 +0200 Subject: [PATCH] Add tails VM --- .../virtualisation/create-service.nix | 2 +- hosts/chocolatebar/virtualisation/default.nix | 24 +++ .../chocolatebar/virtualisation/guest-xml.nix | 4 +- .../chocolatebar/virtualisation/tails-xml.nix | 183 ++++++++++++++++++ 4 files changed, 210 insertions(+), 3 deletions(-) create mode 100644 hosts/chocolatebar/virtualisation/tails-xml.nix diff --git a/hosts/chocolatebar/virtualisation/create-service.nix b/hosts/chocolatebar/virtualisation/create-service.nix index 2f174e99..00fd21da 100644 --- a/hosts/chocolatebar/virtualisation/create-service.nix +++ b/hosts/chocolatebar/virtualisation/create-service.nix @@ -15,7 +15,7 @@ in script = let networkXML = pkgs.writeText "network.xml" (import ./network-xml.nix { inherit config; inherit pkgs; inherit lib; }); - machineXML = pkgs.writeText "${vm.name}.xml" (generateXML { inherit config; inherit pkgs; inherit lib; inherit vm; varsFile = varsFile; }); + machineXML = pkgs.writeText "${vm.name}.xml" (vm.generateXML { inherit config; inherit pkgs; inherit lib; inherit vm; varsFile = varsFile; }); in '' echo "Checking if ${vm.name} is already running" diff --git a/hosts/chocolatebar/virtualisation/default.nix b/hosts/chocolatebar/virtualisation/default.nix index 730e5a99..24fa205c 100644 --- a/hosts/chocolatebar/virtualisation/default.nix +++ b/hosts/chocolatebar/virtualisation/default.nix @@ -4,8 +4,11 @@ let psCfg = config.pub-solar; xdg = config.home-manager.users."${psCfg.user.name}".xdg; createService = import ./create-service.nix; + generateXML = import ./guest-xml.nix; + generateTailsXML = import ./tails-xml.nix; isolateGPU = "rx550x"; + memory = 48; # in GB handOverUSBDevices = false; isolateAnyGPU = isolateGPU != null; @@ -31,8 +34,10 @@ in id = "http://microsoft.com/win/10"; gpu = true; mountHome = false; + memory = memory; isolateGPU = isolateGPU; handOverUSBDevices = handOverUSBDevices; + generateXML = generateXML; }; }; vm-manjaro = createService { @@ -45,8 +50,27 @@ in id = "https://manjaro.org/download/#i3"; gpu = true; mountHome = true; + memory = memory; isolateGPU = isolateGPU; handOverUSBDevices = handOverUSBDevices; + generateXML = generateXML; + }; + }; + vm-tails = createService { + inherit config; + inherit pkgs; + inherit lib; + vm = { + name = "tails"; + disk = "/var/lib/vms/tails/tails-amd64-5.4.iso"; + # disk = "/var/lib/vms/nixos/nixos-minimal.iso"; + id = "https://tails.boum.org/install/index.en.html"; + gpu = false; + mountHome = false; + memory = 16; + isolateGPU = isolateGPU; + handOverUSBDevices = false; + generateXML = generateTailsXML; }; }; }; diff --git a/hosts/chocolatebar/virtualisation/guest-xml.nix b/hosts/chocolatebar/virtualisation/guest-xml.nix index 801e0d77..117e4da5 100644 --- a/hosts/chocolatebar/virtualisation/guest-xml.nix +++ b/hosts/chocolatebar/virtualisation/guest-xml.nix @@ -13,8 +13,8 @@ in - 33554432 - 33554432 + ${toString vm.memory} + ${toString vm.memory} 12 diff --git a/hosts/chocolatebar/virtualisation/tails-xml.nix b/hosts/chocolatebar/virtualisation/tails-xml.nix new file mode 100644 index 00000000..5efefb22 --- /dev/null +++ b/hosts/chocolatebar/virtualisation/tails-xml.nix @@ -0,0 +1,183 @@ +{ config, pkgs, lib, vm, varsFile, ... }: +let + psCfg = config.pub-solar; + xdg = config.home-manager.users."${psCfg.user.name}".xdg; + home = config.home-manager.users."${psCfg.user.name}".home; +in +'' + + ${vm.name} + UUID + + + + + + ${toString vm.memory} + ${toString vm.memory} + 8 + + hvm + + + + + + + + + + + + + + destroy + restart + destroy + + + + + + /run/libvirt/nix-emulators/qemu-system-x86_64 + + + + + +
+ + +
+ + + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + +
+ + +
+ + + + + +
+ + + + + + + + + + + +
+ + + +
+ + +
+ + + + + + + + +
+ +