From e2a68ae4220d03b0f1acd0b6ba71536658a2a443 Mon Sep 17 00:00:00 2001 From: 514fpv Date: Sun, 24 Mar 2024 11:10:09 +0800 Subject: [PATCH] feat(virtualbox): add kvm virtualbox host --- global/virtualbox/default.nix | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 global/virtualbox/default.nix diff --git a/global/virtualbox/default.nix b/global/virtualbox/default.nix new file mode 100644 index 00000000..bf705e14 --- /dev/null +++ b/global/virtualbox/default.nix @@ -0,0 +1,34 @@ +{ pkgs +, lib +, config +, ... }: with lib; let + cfg = config.global.virtualbox; +in { + options.global.virtualbox = { + enable = mkEnableOption "virtualbox host (kvm)"; + }; + + config = mkIf cfg.enable { + virtualisation.virtualbox.host = { + enable = true; + enableKvm = true; + enableExtensionPack = true; + + enableHardening = false; + addNetworkInterface = false; + }; + + # allow virtualbox USB passthrough + users.adminGroups = [ "vboxusers" ]; + + users.home.persist.directories = [ + ".config/VirtualBox" + ]; + + users.homeModules = [ { + wayland.windowManager.sway.config.window.commands = [ + { criteria.class = "VirtualBox Manager"; command = "floating enable"; } + ]; + } ]; + }; +}