mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-17 15:22:59 +01:00
a3118792a5
svn path=/nixos/trunk/; revision=34473
83 lines
1.8 KiB
Nix
83 lines
1.8 KiB
Nix
# Module for VirtualBox guests.
|
|
|
|
{ config, pkgs, ... }:
|
|
|
|
with pkgs.lib;
|
|
|
|
let
|
|
|
|
cfg = config.services.virtualbox;
|
|
kernel = config.boot.kernelPackages;
|
|
|
|
in
|
|
|
|
if (pkgs.stdenv.isi686 || pkgs.stdenv.isx86_64) then
|
|
{
|
|
|
|
###### interface
|
|
|
|
options = {
|
|
|
|
services.virtualbox = {
|
|
|
|
enable = mkOption {
|
|
default = false;
|
|
description = "Whether to enable the VirtualBox service and other guest additions.";
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
###### implementation
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
environment.systemPackages = [ kernel.virtualboxGuestAdditions ];
|
|
|
|
boot.extraModulePackages = [ kernel.virtualboxGuestAdditions ];
|
|
|
|
jobs.virtualbox =
|
|
{ description = "VirtualBox service";
|
|
|
|
startOn = "started udev";
|
|
|
|
exec = "${kernel.virtualboxGuestAdditions}/sbin/VBoxService --foreground";
|
|
};
|
|
|
|
services.xserver.videoDrivers = mkOverride 50 [ "virtualbox" ];
|
|
|
|
services.xserver.config =
|
|
''
|
|
Section "InputDevice"
|
|
Identifier "VBoxMouse"
|
|
Driver "vboxmouse"
|
|
EndSection
|
|
'';
|
|
|
|
services.xserver.serverLayoutSection =
|
|
''
|
|
InputDevice "VBoxMouse"
|
|
'';
|
|
|
|
services.xserver.displayManager.sessionCommands =
|
|
''
|
|
PATH=${makeSearchPath "bin" [ pkgs.gnugrep pkgs.which pkgs.xorg.xorgserver ]}:$PATH \
|
|
${kernel.virtualboxGuestAdditions}/bin/VBoxClient-all
|
|
'';
|
|
|
|
services.udev.extraRules =
|
|
''
|
|
# /dev/vboxuser is necessary for VBoxClient to work. Maybe we
|
|
# should restrict this to logged-in users.
|
|
KERNEL=="vboxuser", OWNER="root", GROUP="root", MODE="0666"
|
|
'';
|
|
|
|
# Make the ACPI Shutdown command to do the right thing.
|
|
services.acpid.enable = true;
|
|
services.acpid.powerEventCommands = "poweroff";
|
|
};
|
|
|
|
}
|
|
else {}
|