2012-03-01 21:10:08 +01:00
|
|
|
{ config, pkgs, ... }:
|
|
|
|
|
|
|
|
with pkgs.lib;
|
|
|
|
|
2012-03-10 15:34:40 +01:00
|
|
|
let virtualbox = config.boot.kernelPackages.virtualbox; in
|
|
|
|
|
2012-03-01 21:10:08 +01:00
|
|
|
{
|
|
|
|
boot.kernelModules = [ "vboxdrv" "vboxnetadp" "vboxnetflt" ];
|
2012-03-10 15:34:40 +01:00
|
|
|
boot.extraModulePackages = [ virtualbox ];
|
|
|
|
environment.systemPackages = [ virtualbox ];
|
2012-03-01 21:10:08 +01:00
|
|
|
|
2012-03-20 17:30:43 +01:00
|
|
|
users.extraGroups = singleton { name = "vboxusers"; };
|
2012-08-20 22:19:57 +02:00
|
|
|
|
2012-03-20 17:30:43 +01:00
|
|
|
services.udev.extraRules =
|
|
|
|
''
|
2012-08-20 22:19:57 +02:00
|
|
|
KERNEL=="vboxdrv", OWNER="root", GROUP="vboxusers", MODE="0660", TAG+="systemd"
|
|
|
|
KERNEL=="vboxnetctl", OWNER="root", GROUP="root", MODE="0600", TAG+="systemd"
|
2013-05-04 11:15:24 +02:00
|
|
|
SUBSYSTEM=="usb_device", ACTION=="add", RUN+="${virtualbox}/libexec/virtualbox/VBoxCreateUSBNode.sh $major $minor $attr{bDeviceClass}"
|
|
|
|
SUBSYSTEM=="usb", ACTION=="add", ENV{DEVTYPE}=="usb_device", RUN+="${virtualbox}/libexec/virtualbox/VBoxCreateUSBNode.sh $major $minor $attr{bDeviceClass}"
|
|
|
|
SUBSYSTEM=="usb_device", ACTION=="remove", RUN+="${virtualbox}/libexec/virtualbox/VBoxCreateUSBNode.sh --remove $major $minor"
|
|
|
|
SUBSYSTEM=="usb", ACTION=="remove", ENV{DEVTYPE}=="usb_device", RUN+="${virtualbox}/libexec/virtualbox/VBoxCreateUSBNode.sh --remove $major $minor"
|
2012-03-20 17:30:43 +01:00
|
|
|
'';
|
2012-03-21 13:28:14 +01:00
|
|
|
|
|
|
|
# Since we lack the right setuid binaries, set up a host-only network by default.
|
2012-08-20 22:19:57 +02:00
|
|
|
|
|
|
|
jobs."vboxnet0" =
|
|
|
|
{ description = "VirtualBox vboxnet0 Interface";
|
|
|
|
requires = [ "dev-vboxnetctl.device" ];
|
|
|
|
after = [ "dev-vboxnetctl.device" ];
|
2012-10-11 04:47:50 +02:00
|
|
|
wantedBy = [ "network.target" "sys-subsystem-net-devices-vboxnet0.device" ];
|
2012-03-21 13:28:14 +01:00
|
|
|
path = [ virtualbox ];
|
2012-08-20 22:19:57 +02:00
|
|
|
preStart =
|
2012-03-21 13:28:14 +01:00
|
|
|
''
|
|
|
|
if ! [ -e /sys/class/net/vboxnet0 ]; then
|
|
|
|
VBoxManage hostonlyif create
|
|
|
|
fi
|
|
|
|
'';
|
2012-08-20 22:19:57 +02:00
|
|
|
postStop =
|
|
|
|
''
|
|
|
|
VBoxManage hostonlyif remove vboxnet0
|
|
|
|
'';
|
2012-03-21 13:28:14 +01:00
|
|
|
};
|
|
|
|
|
2012-11-02 17:08:11 +01:00
|
|
|
networking.interfaces.vboxnet0 = { ipAddress = "192.168.56.1"; prefixLength = 24; };
|
2012-03-01 21:10:08 +01:00
|
|
|
}
|