summaryrefslogtreecommitdiff
path: root/modules/virt.nix
diff options
context:
space:
mode:
Diffstat (limited to 'modules/virt.nix')
-rw-r--r--modules/virt.nix35
1 files changed, 35 insertions, 0 deletions
diff --git a/modules/virt.nix b/modules/virt.nix
new file mode 100644
index 0000000..416f1c4
--- /dev/null
+++ b/modules/virt.nix
@@ -0,0 +1,35 @@
+{pkgs, config, lib, ...}:
+let
+ cfg = config.addons.virtualisation;
+in
+{
+ options.addons.virtualisation = {
+ host = lib.mkEnableOption "Allow to host vm's and containers";
+ guest = lib.mkEnableOption "Enable guest agents";
+ };
+
+ config = lib.mkMerge([
+ (lib.mkIf cfg.host {
+ environment.systemPackages = with pkgs; [
+ qemu
+ ];
+ virtualisation = {
+ docker.enable = true;
+ libvirtd = {
+ enable = true;
+ qemu = {
+ swtpm.enable = true;
+ vhostUserPackages = with pkgs; [ virtiofsd ];
+ ovmf.enable = true;
+ ovmf.packages = [ pkgs.OVMFFull.fd ];
+ };
+ };
+ };
+
+ })
+ (lib.mkIf cfg.guest {
+ virtualisation.spiceUSBRedirection.enable = true;
+ services.spice-vdagentd.enable = true;
+ })
+ ]);
+}