mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-04 21:03:15 +00:00
86b695a18e
Using $storepath/sbin is deprecated according to commit 98cedb3
, so
let's avoid putting anything in .../sbin for the guest additions.
This is a continuation of the initial commit done by @ctheune at
1fb1360, which unfortunately broke VM tests and only changed the path of
the mount.vboxsf helper.
With this commit, the VM test is fixed and I've also verified on my
machine that it is indeed working again.
Signed-off-by: aszlig <aszlig@redmoonstudios.org>
93 lines
2.1 KiB
Nix
93 lines
2.1 KiB
Nix
# Module for VirtualBox guests.
|
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
cfg = config.services.virtualboxGuest;
|
|
kernel = config.boot.kernelPackages;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
###### interface
|
|
|
|
options = {
|
|
|
|
services.virtualboxGuest = {
|
|
|
|
enable = mkOption {
|
|
default = false;
|
|
description = "Whether to enable the VirtualBox service and other guest additions.";
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
###### implementation
|
|
|
|
config = mkIf cfg.enable {
|
|
assertions = [ {
|
|
assertion = pkgs.stdenv.isi686 || pkgs.stdenv.isx86_64;
|
|
message = "Virtualbox not currently supported on ${pkgs.stdenv.system}";
|
|
} ];
|
|
|
|
environment.systemPackages = [ kernel.virtualboxGuestAdditions ];
|
|
|
|
boot.extraModulePackages = [ kernel.virtualboxGuestAdditions ];
|
|
|
|
boot.kernelModules = [ "vboxsf" ];
|
|
|
|
users.extraGroups.vboxsf.gid = config.ids.gids.vboxsf;
|
|
|
|
systemd.services.virtualbox =
|
|
{ description = "VirtualBox Guest Services";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
requires = [ "dev-vboxguest.device" ];
|
|
after = [ "dev-vboxguest.device" ];
|
|
|
|
unitConfig.ConditionVirtualization = "oracle";
|
|
|
|
serviceConfig.ExecStart = "@${kernel.virtualboxGuestAdditions}/bin/VBoxService 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"
|
|
|
|
# Allow systemd dependencies on vboxguest.
|
|
KERNEL=="vboxguest", TAG+="systemd"
|
|
'';
|
|
};
|
|
|
|
}
|