2012-02-25 12:10:53 -08:00
|
|
|
# Module for VirtualBox guests.
|
|
|
|
|
2010-09-07 06:28:17 -07:00
|
|
|
{ config, pkgs, ... }:
|
|
|
|
|
|
|
|
with pkgs.lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.services.virtualbox;
|
2011-09-19 06:20:09 -07:00
|
|
|
kernel = config.boot.kernelPackages;
|
2010-09-07 06:28:17 -07:00
|
|
|
|
|
|
|
in
|
|
|
|
|
2012-10-10 13:49:47 -07:00
|
|
|
optionalAttrs (pkgs.stdenv.isi686 || pkgs.stdenv.isx86_64) # ugly...
|
2010-09-07 06:28:17 -07:00
|
|
|
{
|
|
|
|
|
|
|
|
###### interface
|
2011-09-14 11:20:50 -07:00
|
|
|
|
2010-09-07 06:28:17 -07:00
|
|
|
options = {
|
2011-09-14 11:20:50 -07:00
|
|
|
|
2010-09-07 06:28:17 -07:00
|
|
|
services.virtualbox = {
|
2011-09-14 11:20:50 -07:00
|
|
|
|
2010-09-07 06:28:17 -07:00
|
|
|
enable = mkOption {
|
|
|
|
default = false;
|
|
|
|
description = "Whether to enable the VirtualBox service and other guest additions.";
|
2011-09-14 11:20:50 -07:00
|
|
|
};
|
2010-09-07 06:28:17 -07:00
|
|
|
|
|
|
|
};
|
2011-09-14 11:20:50 -07:00
|
|
|
|
2010-09-07 06:28:17 -07:00
|
|
|
};
|
2011-09-14 11:20:50 -07:00
|
|
|
|
2010-09-07 06:28:17 -07:00
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
|
2012-02-25 12:10:53 -08:00
|
|
|
environment.systemPackages = [ kernel.virtualboxGuestAdditions ];
|
2011-08-09 12:53:01 -07:00
|
|
|
|
2011-09-19 06:20:09 -07:00
|
|
|
boot.extraModulePackages = [ kernel.virtualboxGuestAdditions ];
|
2011-09-14 11:20:50 -07:00
|
|
|
|
2014-02-05 09:38:03 -08:00
|
|
|
boot.kernelModules = [ "vboxsf" ];
|
|
|
|
|
2013-08-23 02:33:24 -07:00
|
|
|
users.extraGroups.vboxsf.gid = config.ids.gids.vboxsf;
|
2012-12-31 13:00:02 -08:00
|
|
|
|
2013-10-09 04:30:57 -07:00
|
|
|
systemd.services.virtualbox =
|
2012-08-23 07:25:27 -07:00
|
|
|
{ description = "VirtualBox Guest Services";
|
2011-09-14 11:20:50 -07:00
|
|
|
|
2012-08-06 11:59:58 -07:00
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
requires = [ "dev-vboxguest.device" ];
|
|
|
|
after = [ "dev-vboxguest.device" ];
|
2010-09-07 06:28:17 -07:00
|
|
|
|
2013-10-09 04:30:57 -07:00
|
|
|
unitConfig.ConditionVirtualization = "oracle";
|
|
|
|
|
|
|
|
serviceConfig.ExecStart = "@${kernel.virtualboxGuestAdditions}/sbin/VBoxService VBoxService --foreground";
|
2010-09-07 06:28:17 -07:00
|
|
|
};
|
|
|
|
|
2014-03-29 02:28:37 -07:00
|
|
|
hardware.opengl.videoDrivers = mkOverride 50 [ "virtualbox" ];
|
2012-03-15 18:03:09 -07:00
|
|
|
|
|
|
|
services.xserver.config =
|
|
|
|
''
|
|
|
|
Section "InputDevice"
|
|
|
|
Identifier "VBoxMouse"
|
|
|
|
Driver "vboxmouse"
|
|
|
|
EndSection
|
|
|
|
'';
|
|
|
|
|
|
|
|
services.xserver.serverLayoutSection =
|
|
|
|
''
|
|
|
|
InputDevice "VBoxMouse"
|
|
|
|
'';
|
2012-08-06 11:59:58 -07:00
|
|
|
|
2012-03-15 18:29:51 -07:00
|
|
|
services.xserver.displayManager.sessionCommands =
|
|
|
|
''
|
|
|
|
PATH=${makeSearchPath "bin" [ pkgs.gnugrep pkgs.which pkgs.xorg.xorgserver ]}:$PATH \
|
|
|
|
${kernel.virtualboxGuestAdditions}/bin/VBoxClient-all
|
|
|
|
'';
|
2012-03-23 04:52:06 -07:00
|
|
|
|
|
|
|
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"
|
2012-08-06 11:59:58 -07:00
|
|
|
|
|
|
|
# Allow systemd dependencies on vboxguest.
|
|
|
|
KERNEL=="vboxguest", TAG+="systemd"
|
2012-03-23 04:52:06 -07:00
|
|
|
'';
|
2010-09-07 06:28:17 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|