virtualbox guest module: make x11 optional

+26 -17
+26 -17
nixos/modules/virtualisation/virtualbox-guest.nix
··· 15 15 16 16 ###### interface 17 17 18 - options.virtualisation.virtualbox.guest.enable = mkOption { 19 - default = false; 20 - description = "Whether to enable the VirtualBox service and other guest additions."; 18 + options.virtualisation.virtualbox.guest = { 19 + enable = mkOption { 20 + default = false; 21 + type = types.bool; 22 + description = "Whether to enable the VirtualBox service and other guest additions."; 23 + }; 24 + 25 + x11 = mkOption { 26 + default = true; 27 + type = types.bool; 28 + description = "Whether to enable x11 graphics"; 29 + }; 21 30 }; 22 31 23 32 ###### implementation 24 33 25 - config = mkIf cfg.enable { 26 - assertions = [ { 34 + config = mkIf cfg.enable (mkMerge [{ 35 + assertions = [{ 27 36 assertion = pkgs.stdenv.isi686 || pkgs.stdenv.isx86_64; 28 37 message = "Virtualbox not currently supported on ${pkgs.stdenv.system}"; 29 - } ]; 38 + }]; 30 39 31 40 environment.systemPackages = [ kernel.virtualboxGuestAdditions ]; 32 41 ··· 49 58 serviceConfig.ExecStart = "@${kernel.virtualboxGuestAdditions}/bin/VBoxService VBoxService --foreground"; 50 59 }; 51 60 61 + services.udev.extraRules = 62 + '' 63 + # /dev/vboxuser is necessary for VBoxClient to work. Maybe we 64 + # should restrict this to logged-in users. 65 + KERNEL=="vboxuser", OWNER="root", GROUP="root", MODE="0666" 66 + 67 + # Allow systemd dependencies on vboxguest. 68 + SUBSYSTEM=="misc", KERNEL=="vboxguest", TAG+="systemd" 69 + ''; 70 + } (mkIf cfg.x11 { 52 71 services.xserver.videoDrivers = mkOverride 50 [ "virtualbox" "modesetting" ]; 53 72 54 73 services.xserver.config = ··· 69 88 PATH=${makeBinPath [ pkgs.gnugrep pkgs.which pkgs.xorg.xorgserver.out ]}:$PATH \ 70 89 ${kernel.virtualboxGuestAdditions}/bin/VBoxClient-all 71 90 ''; 72 - 73 - services.udev.extraRules = 74 - '' 75 - # /dev/vboxuser is necessary for VBoxClient to work. Maybe we 76 - # should restrict this to logged-in users. 77 - KERNEL=="vboxuser", OWNER="root", GROUP="root", MODE="0666" 78 - 79 - # Allow systemd dependencies on vboxguest. 80 - SUBSYSTEM=="misc", KERNEL=="vboxguest", TAG+="systemd" 81 - ''; 82 - }; 91 + })]); 83 92 84 93 }