mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-10 03:23:29 +03:00
virtualbox: nixfmt
This commit is contained in:
parent
2a3b139da1
commit
53b37c99b4
7 changed files with 617 additions and 348 deletions
|
@ -1,5 +1,10 @@
|
||||||
# Module for VirtualBox guests.
|
# Module for VirtualBox guests.
|
||||||
{ config, lib, pkgs, ... }:
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
let
|
let
|
||||||
cfg = config.virtualisation.virtualbox.guest;
|
cfg = config.virtualisation.virtualbox.guest;
|
||||||
kernel = config.boot.kernelPackages;
|
kernel = config.boot.kernelPackages;
|
||||||
|
@ -28,7 +33,20 @@ let
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
(lib.mkRenamedOptionModule [ "virtualisation" "virtualbox" "guest" "draganddrop" ] [ "virtualisation" "virtualbox" "guest" "dragAndDrop" ])
|
(lib.mkRenamedOptionModule
|
||||||
|
[
|
||||||
|
"virtualisation"
|
||||||
|
"virtualbox"
|
||||||
|
"guest"
|
||||||
|
"draganddrop"
|
||||||
|
]
|
||||||
|
[
|
||||||
|
"virtualisation"
|
||||||
|
"virtualbox"
|
||||||
|
"guest"
|
||||||
|
"dragAndDrop"
|
||||||
|
]
|
||||||
|
)
|
||||||
];
|
];
|
||||||
|
|
||||||
options.virtualisation.virtualbox.guest = {
|
options.virtualisation.virtualbox.guest = {
|
||||||
|
@ -59,36 +77,38 @@ in
|
||||||
|
|
||||||
###### implementation
|
###### implementation
|
||||||
|
|
||||||
config = lib.mkIf cfg.enable (lib.mkMerge [
|
config = lib.mkIf cfg.enable (
|
||||||
{
|
lib.mkMerge [
|
||||||
assertions = [{
|
{
|
||||||
assertion = pkgs.stdenv.hostPlatform.isx86;
|
assertions = [
|
||||||
message = "Virtualbox not currently supported on ${pkgs.stdenv.hostPlatform.system}";
|
{
|
||||||
}];
|
assertion = pkgs.stdenv.hostPlatform.isx86;
|
||||||
|
message = "Virtualbox not currently supported on ${pkgs.stdenv.hostPlatform.system}";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
environment.systemPackages = [ kernel.virtualboxGuestAdditions ];
|
environment.systemPackages = [ kernel.virtualboxGuestAdditions ];
|
||||||
|
|
||||||
boot.extraModulePackages = [ kernel.virtualboxGuestAdditions ];
|
boot.extraModulePackages = [ kernel.virtualboxGuestAdditions ];
|
||||||
|
|
||||||
boot.supportedFilesystems = [ "vboxsf" ];
|
boot.supportedFilesystems = [ "vboxsf" ];
|
||||||
boot.initrd.supportedFilesystems = [ "vboxsf" ];
|
boot.initrd.supportedFilesystems = [ "vboxsf" ];
|
||||||
|
|
||||||
users.groups.vboxsf.gid = config.ids.gids.vboxsf;
|
users.groups.vboxsf.gid = config.ids.gids.vboxsf;
|
||||||
|
|
||||||
systemd.services.virtualbox = {
|
systemd.services.virtualbox = {
|
||||||
description = "VirtualBox Guest Services";
|
description = "VirtualBox Guest Services";
|
||||||
|
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
requires = [ "dev-vboxguest.device" ];
|
requires = [ "dev-vboxguest.device" ];
|
||||||
after = [ "dev-vboxguest.device" ];
|
after = [ "dev-vboxguest.device" ];
|
||||||
|
|
||||||
unitConfig.ConditionVirtualization = "oracle";
|
unitConfig.ConditionVirtualization = "oracle";
|
||||||
|
|
||||||
serviceConfig.ExecStart = "@${kernel.virtualboxGuestAdditions}/bin/VBoxService VBoxService --foreground";
|
serviceConfig.ExecStart = "@${kernel.virtualboxGuestAdditions}/bin/VBoxService VBoxService --foreground";
|
||||||
};
|
};
|
||||||
|
|
||||||
services.udev.extraRules =
|
services.udev.extraRules = ''
|
||||||
''
|
|
||||||
# /dev/vboxuser is necessary for VBoxClient to work. Maybe we
|
# /dev/vboxuser is necessary for VBoxClient to work. Maybe we
|
||||||
# should restrict this to logged-in users.
|
# should restrict this to logged-in users.
|
||||||
KERNEL=="vboxuser", OWNER="root", GROUP="root", MODE="0666"
|
KERNEL=="vboxuser", OWNER="root", GROUP="root", MODE="0666"
|
||||||
|
@ -97,22 +117,17 @@ in
|
||||||
SUBSYSTEM=="misc", KERNEL=="vboxguest", TAG+="systemd"
|
SUBSYSTEM=="misc", KERNEL=="vboxguest", TAG+="systemd"
|
||||||
'';
|
'';
|
||||||
|
|
||||||
systemd.user.services.virtualboxClientVmsvga = mkVirtualBoxUserService "--vmsvga-session";
|
systemd.user.services.virtualboxClientVmsvga = mkVirtualBoxUserService "--vmsvga-session";
|
||||||
}
|
}
|
||||||
(
|
(lib.mkIf cfg.clipboard {
|
||||||
lib.mkIf cfg.clipboard {
|
|
||||||
systemd.user.services.virtualboxClientClipboard = mkVirtualBoxUserService "--clipboard";
|
systemd.user.services.virtualboxClientClipboard = mkVirtualBoxUserService "--clipboard";
|
||||||
}
|
})
|
||||||
)
|
(lib.mkIf cfg.seamless {
|
||||||
(
|
|
||||||
lib.mkIf cfg.seamless {
|
|
||||||
systemd.user.services.virtualboxClientSeamless = mkVirtualBoxUserService "--seamless";
|
systemd.user.services.virtualboxClientSeamless = mkVirtualBoxUserService "--seamless";
|
||||||
}
|
})
|
||||||
)
|
(lib.mkIf cfg.dragAndDrop {
|
||||||
(
|
|
||||||
lib.mkIf cfg.dragAndDrop {
|
|
||||||
systemd.user.services.virtualboxClientDragAndDrop = mkVirtualBoxUserService "--draganddrop";
|
systemd.user.services.virtualboxClientDragAndDrop = mkVirtualBoxUserService "--draganddrop";
|
||||||
}
|
})
|
||||||
)
|
]
|
||||||
]);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,19 @@
|
||||||
{ config, lib, pkgs, ... }:
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
let
|
let
|
||||||
cfg = config.virtualisation.virtualbox.host;
|
cfg = config.virtualisation.virtualbox.host;
|
||||||
|
|
||||||
virtualbox = cfg.package.override {
|
virtualbox = cfg.package.override {
|
||||||
inherit (cfg) enableHardening headless enableWebService enableKvm;
|
inherit (cfg)
|
||||||
|
enableHardening
|
||||||
|
headless
|
||||||
|
enableWebService
|
||||||
|
enableKvm
|
||||||
|
;
|
||||||
extensionPack = if cfg.enableExtensionPack then pkgs.virtualboxExtpack else null;
|
extensionPack = if cfg.enableExtensionPack then pkgs.virtualboxExtpack else null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -93,93 +103,119 @@ in
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = lib.mkIf cfg.enable (lib.mkMerge [{
|
config = lib.mkIf cfg.enable (
|
||||||
warnings = lib.mkIf (pkgs.config.virtualbox.enableExtensionPack or false)
|
lib.mkMerge [
|
||||||
["'nixpkgs.virtualbox.enableExtensionPack' has no effect, please use 'virtualisation.virtualbox.host.enableExtensionPack'"];
|
|
||||||
environment.systemPackages = [ virtualbox ];
|
|
||||||
|
|
||||||
security.wrappers = let
|
|
||||||
mkSuid = program: {
|
|
||||||
source = "${virtualbox}/libexec/virtualbox/${program}";
|
|
||||||
owner = "root";
|
|
||||||
group = "vboxusers";
|
|
||||||
setuid = true;
|
|
||||||
};
|
|
||||||
executables = [
|
|
||||||
"VBoxHeadless"
|
|
||||||
"VBoxNetAdpCtl"
|
|
||||||
"VBoxNetDHCP"
|
|
||||||
"VBoxNetNAT"
|
|
||||||
"VBoxVolInfo"
|
|
||||||
] ++ (lib.optionals (!cfg.headless) [
|
|
||||||
"VBoxSDL"
|
|
||||||
"VirtualBoxVM"
|
|
||||||
]);
|
|
||||||
in lib.mkIf cfg.enableHardening
|
|
||||||
(builtins.listToAttrs (map (x: { name = x; value = mkSuid x; }) executables));
|
|
||||||
|
|
||||||
users.groups.vboxusers.gid = config.ids.gids.vboxusers;
|
|
||||||
|
|
||||||
services.udev.extraRules =
|
|
||||||
''
|
|
||||||
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"
|
|
||||||
'';
|
|
||||||
} (lib.mkIf cfg.enableKvm {
|
|
||||||
assertions = [
|
|
||||||
{
|
{
|
||||||
assertion = !cfg.addNetworkInterface;
|
warnings = lib.mkIf (pkgs.config.virtualbox.enableExtensionPack or false) [
|
||||||
message = "VirtualBox KVM only supports standard NAT networking for VMs. Please turn off virtualisation.virtualbox.host.addNetworkInterface.";
|
"'nixpkgs.virtualbox.enableExtensionPack' has no effect, please use 'virtualisation.virtualbox.host.enableExtensionPack'"
|
||||||
|
];
|
||||||
|
environment.systemPackages = [ virtualbox ];
|
||||||
|
|
||||||
|
security.wrappers =
|
||||||
|
let
|
||||||
|
mkSuid = program: {
|
||||||
|
source = "${virtualbox}/libexec/virtualbox/${program}";
|
||||||
|
owner = "root";
|
||||||
|
group = "vboxusers";
|
||||||
|
setuid = true;
|
||||||
|
};
|
||||||
|
executables =
|
||||||
|
[
|
||||||
|
"VBoxHeadless"
|
||||||
|
"VBoxNetAdpCtl"
|
||||||
|
"VBoxNetDHCP"
|
||||||
|
"VBoxNetNAT"
|
||||||
|
"VBoxVolInfo"
|
||||||
|
]
|
||||||
|
++ (lib.optionals (!cfg.headless) [
|
||||||
|
"VBoxSDL"
|
||||||
|
"VirtualBoxVM"
|
||||||
|
]);
|
||||||
|
in
|
||||||
|
lib.mkIf cfg.enableHardening (
|
||||||
|
builtins.listToAttrs (
|
||||||
|
map (x: {
|
||||||
|
name = x;
|
||||||
|
value = mkSuid x;
|
||||||
|
}) executables
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
users.groups.vboxusers.gid = config.ids.gids.vboxusers;
|
||||||
|
|
||||||
|
services.udev.extraRules = ''
|
||||||
|
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"
|
||||||
|
'';
|
||||||
}
|
}
|
||||||
];
|
(lib.mkIf cfg.enableKvm {
|
||||||
}) (lib.mkIf (!cfg.enableKvm) {
|
assertions = [
|
||||||
boot.kernelModules = [ "vboxdrv" "vboxnetadp" "vboxnetflt" ];
|
{
|
||||||
boot.extraModulePackages = [ kernelModules ];
|
assertion = !cfg.addNetworkInterface;
|
||||||
|
message = "VirtualBox KVM only supports standard NAT networking for VMs. Please turn off virtualisation.virtualbox.host.addNetworkInterface.";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
})
|
||||||
|
(lib.mkIf (!cfg.enableKvm) {
|
||||||
|
boot.kernelModules = [
|
||||||
|
"vboxdrv"
|
||||||
|
"vboxnetadp"
|
||||||
|
"vboxnetflt"
|
||||||
|
];
|
||||||
|
boot.extraModulePackages = [ kernelModules ];
|
||||||
|
|
||||||
services.udev.extraRules =
|
services.udev.extraRules = ''
|
||||||
''
|
KERNEL=="vboxdrv", OWNER="root", GROUP="vboxusers", MODE="0660", TAG+="systemd"
|
||||||
KERNEL=="vboxdrv", OWNER="root", GROUP="vboxusers", MODE="0660", TAG+="systemd"
|
KERNEL=="vboxdrvu", OWNER="root", GROUP="root", MODE="0666", TAG+="systemd"
|
||||||
KERNEL=="vboxdrvu", OWNER="root", GROUP="root", MODE="0666", TAG+="systemd"
|
KERNEL=="vboxnetctl", OWNER="root", GROUP="vboxusers", MODE="0660", TAG+="systemd"
|
||||||
KERNEL=="vboxnetctl", OWNER="root", GROUP="vboxusers", MODE="0660", TAG+="systemd"
|
'';
|
||||||
'';
|
|
||||||
|
|
||||||
# Since we lack the right setuid/setcap binaries, set up a host-only network by default.
|
# Since we lack the right setuid/setcap binaries, set up a host-only network by default.
|
||||||
}) (lib.mkIf cfg.addNetworkInterface {
|
})
|
||||||
systemd.services.vboxnet0 =
|
(lib.mkIf cfg.addNetworkInterface {
|
||||||
{ description = "VirtualBox vboxnet0 Interface";
|
systemd.services.vboxnet0 = {
|
||||||
requires = [ "dev-vboxnetctl.device" ];
|
description = "VirtualBox vboxnet0 Interface";
|
||||||
after = [ "dev-vboxnetctl.device" ];
|
requires = [ "dev-vboxnetctl.device" ];
|
||||||
wantedBy = [ "network.target" "sys-subsystem-net-devices-vboxnet0.device" ];
|
after = [ "dev-vboxnetctl.device" ];
|
||||||
path = [ virtualbox ];
|
wantedBy = [
|
||||||
serviceConfig.RemainAfterExit = true;
|
"network.target"
|
||||||
serviceConfig.Type = "oneshot";
|
"sys-subsystem-net-devices-vboxnet0.device"
|
||||||
serviceConfig.PrivateTmp = true;
|
];
|
||||||
environment.VBOX_USER_HOME = "/tmp";
|
path = [ virtualbox ];
|
||||||
script =
|
serviceConfig.RemainAfterExit = true;
|
||||||
''
|
serviceConfig.Type = "oneshot";
|
||||||
|
serviceConfig.PrivateTmp = true;
|
||||||
|
environment.VBOX_USER_HOME = "/tmp";
|
||||||
|
script = ''
|
||||||
if ! [ -e /sys/class/net/vboxnet0 ]; then
|
if ! [ -e /sys/class/net/vboxnet0 ]; then
|
||||||
VBoxManage hostonlyif create
|
VBoxManage hostonlyif create
|
||||||
cat /tmp/VBoxSVC.log >&2
|
cat /tmp/VBoxSVC.log >&2
|
||||||
fi
|
fi
|
||||||
'';
|
'';
|
||||||
postStop =
|
postStop = ''
|
||||||
''
|
|
||||||
VBoxManage hostonlyif remove vboxnet0
|
VBoxManage hostonlyif remove vboxnet0
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
networking.interfaces.vboxnet0.ipv4.addresses = [{ address = "192.168.56.1"; prefixLength = 24; }];
|
networking.interfaces.vboxnet0.ipv4.addresses = [
|
||||||
# Make sure NetworkManager won't assume this interface being up
|
{
|
||||||
# means we have internet access.
|
address = "192.168.56.1";
|
||||||
networking.networkmanager.unmanaged = ["vboxnet0"];
|
prefixLength = 24;
|
||||||
}) (lib.mkIf config.networking.useNetworkd {
|
}
|
||||||
systemd.network.networks."40-vboxnet0".extraConfig = ''
|
];
|
||||||
[Link]
|
# Make sure NetworkManager won't assume this interface being up
|
||||||
RequiredForOnline=no
|
# means we have internet access.
|
||||||
'';
|
networking.networkmanager.unmanaged = [ "vboxnet0" ];
|
||||||
})
|
})
|
||||||
|
(lib.mkIf config.networking.useNetworkd {
|
||||||
|
systemd.network.networks."40-vboxnet0".extraConfig = ''
|
||||||
|
[Link]
|
||||||
|
RequiredForOnline=no
|
||||||
|
'';
|
||||||
|
})
|
||||||
|
|
||||||
]);
|
]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,25 +1,74 @@
|
||||||
{ config, stdenv, fetchurl, fetchpatch, callPackage, lib, acpica-tools, dev86, pam, libxslt, libxml2, wrapQtAppsHook
|
{
|
||||||
, libX11, xorgproto, libXext, libXcursor, libXmu, libIDL, SDL2, libcap, libGL, libGLU
|
config,
|
||||||
, libpng, glib, lvm2, libXrandr, libXinerama, libopus, libtpms, qtbase, qtx11extras
|
stdenv,
|
||||||
, qttools, qtsvg, qtwayland, pkg-config, which, docbook_xsl, docbook_xml_dtd_43
|
fetchurl,
|
||||||
, alsa-lib, curl, libvpx, nettools, dbus, substituteAll, gsoap, zlib, xz
|
fetchpatch,
|
||||||
, yasm, glslang
|
callPackage,
|
||||||
, nixosTests
|
lib,
|
||||||
# If open-watcom-bin is not passed, VirtualBox will fall back to use
|
acpica-tools,
|
||||||
# the shipped alternative sources (assembly).
|
dev86,
|
||||||
, open-watcom-bin
|
pam,
|
||||||
, makeself, perl
|
libxslt,
|
||||||
, vulkan-loader
|
libxml2,
|
||||||
, javaBindings ? true, jdk # Almost doesn't affect closure size
|
wrapQtAppsHook,
|
||||||
, pythonBindings ? false, python3
|
libX11,
|
||||||
, extensionPack ? null, fakeroot
|
xorgproto,
|
||||||
, pulseSupport ? config.pulseaudio or stdenv.hostPlatform.isLinux, libpulseaudio
|
libXext,
|
||||||
, enableHardening ? false
|
libXcursor,
|
||||||
, headless ? false
|
libXmu,
|
||||||
, enable32bitGuests ? true
|
libIDL,
|
||||||
, enableWebService ? false
|
SDL2,
|
||||||
, enableKvm ? false
|
libcap,
|
||||||
, extraConfigureFlags ? ""
|
libGL,
|
||||||
|
libGLU,
|
||||||
|
libpng,
|
||||||
|
glib,
|
||||||
|
lvm2,
|
||||||
|
libXrandr,
|
||||||
|
libXinerama,
|
||||||
|
libopus,
|
||||||
|
libtpms,
|
||||||
|
qtbase,
|
||||||
|
qtx11extras,
|
||||||
|
qttools,
|
||||||
|
qtsvg,
|
||||||
|
qtwayland,
|
||||||
|
pkg-config,
|
||||||
|
which,
|
||||||
|
docbook_xsl,
|
||||||
|
docbook_xml_dtd_43,
|
||||||
|
alsa-lib,
|
||||||
|
curl,
|
||||||
|
libvpx,
|
||||||
|
nettools,
|
||||||
|
dbus,
|
||||||
|
substituteAll,
|
||||||
|
gsoap,
|
||||||
|
zlib,
|
||||||
|
xz,
|
||||||
|
yasm,
|
||||||
|
glslang,
|
||||||
|
nixosTests,
|
||||||
|
# If open-watcom-bin is not passed, VirtualBox will fall back to use
|
||||||
|
# the shipped alternative sources (assembly).
|
||||||
|
open-watcom-bin,
|
||||||
|
makeself,
|
||||||
|
perl,
|
||||||
|
vulkan-loader,
|
||||||
|
javaBindings ? true,
|
||||||
|
jdk, # Almost doesn't affect closure size
|
||||||
|
pythonBindings ? false,
|
||||||
|
python3,
|
||||||
|
extensionPack ? null,
|
||||||
|
fakeroot,
|
||||||
|
pulseSupport ? config.pulseaudio or stdenv.hostPlatform.isLinux,
|
||||||
|
libpulseaudio,
|
||||||
|
enableHardening ? false,
|
||||||
|
headless ? false,
|
||||||
|
enable32bitGuests ? true,
|
||||||
|
enableWebService ? false,
|
||||||
|
enableKvm ? false,
|
||||||
|
extraConfigureFlags ? "",
|
||||||
}:
|
}:
|
||||||
|
|
||||||
# The web services use Java infrastructure.
|
# The web services use Java infrastructure.
|
||||||
|
@ -41,12 +90,26 @@ let
|
||||||
|
|
||||||
virtualboxGuestAdditionsIso = callPackage guest-additions-iso/default.nix { };
|
virtualboxGuestAdditionsIso = callPackage guest-additions-iso/default.nix { };
|
||||||
|
|
||||||
inherit (lib) optional optionals optionalString getDev getLib;
|
inherit (lib)
|
||||||
in stdenv.mkDerivation (finalAttrs: {
|
optional
|
||||||
|
optionals
|
||||||
|
optionalString
|
||||||
|
getDev
|
||||||
|
getLib
|
||||||
|
;
|
||||||
|
in
|
||||||
|
stdenv.mkDerivation (finalAttrs: {
|
||||||
pname = "virtualbox";
|
pname = "virtualbox";
|
||||||
version = finalAttrs.virtualboxVersion;
|
version = finalAttrs.virtualboxVersion;
|
||||||
|
|
||||||
inherit buildType virtualboxVersion virtualboxSha256 kvmPatchVersion kvmPatchHash virtualboxGuestAdditionsIso;
|
inherit
|
||||||
|
buildType
|
||||||
|
virtualboxVersion
|
||||||
|
virtualboxSha256
|
||||||
|
kvmPatchVersion
|
||||||
|
kvmPatchHash
|
||||||
|
virtualboxGuestAdditionsIso
|
||||||
|
;
|
||||||
|
|
||||||
src = fetchurl {
|
src = fetchurl {
|
||||||
url = "https://download.virtualbox.org/virtualbox/${finalAttrs.virtualboxVersion}/VirtualBox-${finalAttrs.virtualboxVersion}.tar.bz2";
|
url = "https://download.virtualbox.org/virtualbox/${finalAttrs.virtualboxVersion}/VirtualBox-${finalAttrs.virtualboxVersion}.tar.bz2";
|
||||||
|
@ -55,39 +118,84 @@ in stdenv.mkDerivation (finalAttrs: {
|
||||||
|
|
||||||
outputs = [ "out" ] ++ optional withModsrc "modsrc";
|
outputs = [ "out" ] ++ optional withModsrc "modsrc";
|
||||||
|
|
||||||
nativeBuildInputs = [ pkg-config which docbook_xsl docbook_xml_dtd_43 yasm glslang ]
|
nativeBuildInputs = [
|
||||||
++ optional (!headless) wrapQtAppsHook;
|
pkg-config
|
||||||
|
which
|
||||||
|
docbook_xsl
|
||||||
|
docbook_xml_dtd_43
|
||||||
|
yasm
|
||||||
|
glslang
|
||||||
|
] ++ optional (!headless) wrapQtAppsHook;
|
||||||
|
|
||||||
# Wrap manually because we wrap just a small number of executables.
|
# Wrap manually because we wrap just a small number of executables.
|
||||||
dontWrapQtApps = true;
|
dontWrapQtApps = true;
|
||||||
|
|
||||||
buildInputs = [
|
buildInputs =
|
||||||
acpica-tools dev86 libxslt libxml2 xorgproto libX11 libXext libXcursor libIDL
|
[
|
||||||
libcap glib lvm2 alsa-lib curl libvpx pam makeself perl
|
acpica-tools
|
||||||
libXmu libXrandr libpng libopus libtpms python3 xz ]
|
dev86
|
||||||
|
libxslt
|
||||||
|
libxml2
|
||||||
|
xorgproto
|
||||||
|
libX11
|
||||||
|
libXext
|
||||||
|
libXcursor
|
||||||
|
libIDL
|
||||||
|
libcap
|
||||||
|
glib
|
||||||
|
lvm2
|
||||||
|
alsa-lib
|
||||||
|
curl
|
||||||
|
libvpx
|
||||||
|
pam
|
||||||
|
makeself
|
||||||
|
perl
|
||||||
|
libXmu
|
||||||
|
libXrandr
|
||||||
|
libpng
|
||||||
|
libopus
|
||||||
|
libtpms
|
||||||
|
python3
|
||||||
|
xz
|
||||||
|
]
|
||||||
++ optional javaBindings jdk
|
++ optional javaBindings jdk
|
||||||
++ optional pythonBindings python3 # Python is needed even when not building bindings
|
++ optional pythonBindings python3 # Python is needed even when not building bindings
|
||||||
++ optional pulseSupport libpulseaudio
|
++ optional pulseSupport libpulseaudio
|
||||||
++ optionals headless [ libGL ]
|
++ optionals headless [ libGL ]
|
||||||
++ optionals (!headless) [ qtbase qtx11extras libXinerama SDL2 libGLU ]
|
++ optionals (!headless) [
|
||||||
++ optionals enableWebService [ gsoap zlib ];
|
qtbase
|
||||||
|
qtx11extras
|
||||||
|
libXinerama
|
||||||
|
SDL2
|
||||||
|
libGLU
|
||||||
|
]
|
||||||
|
++ optionals enableWebService [
|
||||||
|
gsoap
|
||||||
|
zlib
|
||||||
|
];
|
||||||
|
|
||||||
hardeningDisable = [ "format" "fortify" "pic" "stackprotector" ];
|
hardeningDisable = [
|
||||||
|
"format"
|
||||||
|
"fortify"
|
||||||
|
"pic"
|
||||||
|
"stackprotector"
|
||||||
|
];
|
||||||
|
|
||||||
prePatch = ''
|
prePatch = ''
|
||||||
set -x
|
set -x
|
||||||
sed -e 's@MKISOFS --version@MKISOFS -version@' \
|
sed -e 's@MKISOFS --version@MKISOFS -version@' \
|
||||||
-e 's@PYTHONDIR=.*@PYTHONDIR=${optionalString pythonBindings python3}@' \
|
-e 's@PYTHONDIR=.*@PYTHONDIR=${optionalString pythonBindings python3}@' \
|
||||||
-e 's@CXX_FLAGS="\(.*\)"@CXX_FLAGS="-std=c++11 \1"@' \
|
-e 's@CXX_FLAGS="\(.*\)"@CXX_FLAGS="-std=c++11 \1"@' \
|
||||||
${optionalString (!headless) ''
|
${
|
||||||
-e 's@TOOLQT5BIN=.*@TOOLQT5BIN="${getDev qtbase}/bin"@' \
|
optionalString (!headless) ''
|
||||||
''} -i configure
|
-e 's@TOOLQT5BIN=.*@TOOLQT5BIN="${getDev qtbase}/bin"@' \
|
||||||
|
''
|
||||||
|
} -i configure
|
||||||
ls kBuild/bin/linux.x86/k* tools/linux.x86/bin/* | xargs -n 1 patchelf --set-interpreter ${stdenv.cc.libc}/lib/ld-linux.so.2
|
ls kBuild/bin/linux.x86/k* tools/linux.x86/bin/* | xargs -n 1 patchelf --set-interpreter ${stdenv.cc.libc}/lib/ld-linux.so.2
|
||||||
ls kBuild/bin/linux.amd64/k* tools/linux.amd64/bin/* | xargs -n 1 patchelf --set-interpreter ${stdenv.cc.libc}/lib/ld-linux-x86-64.so.2
|
ls kBuild/bin/linux.amd64/k* tools/linux.amd64/bin/* | xargs -n 1 patchelf --set-interpreter ${stdenv.cc.libc}/lib/ld-linux-x86-64.so.2
|
||||||
|
|
||||||
grep 'libpulse\.so\.0' src include -rI --files-with-match | xargs sed -i -e '
|
grep 'libpulse\.so\.0' src include -rI --files-with-match | xargs sed -i -e '
|
||||||
${optionalString pulseSupport
|
${optionalString pulseSupport ''s@"libpulse\.so\.0"@"${libpulseaudio.out}/lib/libpulse.so.0"@g''}'
|
||||||
''s@"libpulse\.so\.0"@"${libpulseaudio.out}/lib/libpulse.so.0"@g''}'
|
|
||||||
|
|
||||||
grep 'libdbus-1\.so\.3' src include -rI --files-with-match | xargs sed -i -e '
|
grep 'libdbus-1\.so\.3' src include -rI --files-with-match | xargs sed -i -e '
|
||||||
s@"libdbus-1\.so\.3"@"${dbus.lib}/lib/libdbus-1.so.3"@g'
|
s@"libdbus-1\.so\.3"@"${dbus.lib}/lib/libdbus-1.so.3"@g'
|
||||||
|
@ -100,39 +208,41 @@ in stdenv.mkDerivation (finalAttrs: {
|
||||||
'';
|
'';
|
||||||
|
|
||||||
patches =
|
patches =
|
||||||
optional enableHardening ./hardened.patch
|
optional enableHardening ./hardened.patch
|
||||||
# Since VirtualBox 7.0.8, VBoxSDL requires SDL2, but the build framework uses SDL1
|
# Since VirtualBox 7.0.8, VBoxSDL requires SDL2, but the build framework uses SDL1
|
||||||
++ optionals (!headless) [ ./fix-sdl.patch
|
++ optionals (!headless) [
|
||||||
# No update patch disables check for update function
|
./fix-sdl.patch
|
||||||
# https://bugs.launchpad.net/ubuntu/+source/virtualbox-ose/+bug/272212
|
# No update patch disables check for update function
|
||||||
(fetchpatch {
|
# https://bugs.launchpad.net/ubuntu/+source/virtualbox-ose/+bug/272212
|
||||||
url = "https://salsa.debian.org/pkg-virtualbox-team/virtualbox/-/raw/debian/7.0.14-dfsg-1/debian/patches/16-no-update.patch";
|
(fetchpatch {
|
||||||
hash = "sha256-UJHpuB6QB/BbxJorlqZXUF12lgq8gbLMRHRMsbyqRpY=";
|
url = "https://salsa.debian.org/pkg-virtualbox-team/virtualbox/-/raw/debian/7.0.14-dfsg-1/debian/patches/16-no-update.patch";
|
||||||
})]
|
hash = "sha256-UJHpuB6QB/BbxJorlqZXUF12lgq8gbLMRHRMsbyqRpY=";
|
||||||
++ [ ./extra_symbols.patch ]
|
})
|
||||||
# When hardening is enabled, we cannot use wrapQtApp to ensure that VirtualBoxVM sees
|
]
|
||||||
# the correct environment variables needed for Qt to work, specifically QT_PLUGIN_PATH.
|
++ [ ./extra_symbols.patch ]
|
||||||
# This is because VirtualBoxVM would detect that it is wrapped that and refuse to run,
|
# When hardening is enabled, we cannot use wrapQtApp to ensure that VirtualBoxVM sees
|
||||||
# and also because it would unset QT_PLUGIN_PATH for security reasons. We work around
|
# the correct environment variables needed for Qt to work, specifically QT_PLUGIN_PATH.
|
||||||
# these issues by patching the code to set QT_PLUGIN_PATH to the necessary paths,
|
# This is because VirtualBoxVM would detect that it is wrapped that and refuse to run,
|
||||||
# after the code that unsets it. Note that qtsvg is included so that SVG icons from
|
# and also because it would unset QT_PLUGIN_PATH for security reasons. We work around
|
||||||
# the user's icon theme can be loaded.
|
# these issues by patching the code to set QT_PLUGIN_PATH to the necessary paths,
|
||||||
++ optional (!headless && enableHardening) (substituteAll {
|
# after the code that unsets it. Note that qtsvg is included so that SVG icons from
|
||||||
|
# the user's icon theme can be loaded.
|
||||||
|
++ optional (!headless && enableHardening) (substituteAll {
|
||||||
src = ./qt-env-vars.patch;
|
src = ./qt-env-vars.patch;
|
||||||
qtPluginPath = "${qtbase.bin}/${qtbase.qtPluginPrefix}:${qtsvg.bin}/${qtbase.qtPluginPrefix}:${qtwayland.bin}/${qtbase.qtPluginPrefix}";
|
qtPluginPath = "${qtbase.bin}/${qtbase.qtPluginPrefix}:${qtsvg.bin}/${qtbase.qtPluginPrefix}:${qtwayland.bin}/${qtbase.qtPluginPrefix}";
|
||||||
})
|
})
|
||||||
# While the KVM patch should not break any other behavior if --with-kvm is not specified,
|
# While the KVM patch should not break any other behavior if --with-kvm is not specified,
|
||||||
# we don't take any chances and only apply it if people actually want to use KVM support.
|
# we don't take any chances and only apply it if people actually want to use KVM support.
|
||||||
++ optional enableKvm (fetchpatch {
|
++ optional enableKvm (fetchpatch {
|
||||||
name = "virtualbox-${finalAttrs.virtualboxVersion}-kvm-dev-${finalAttrs.kvmPatchVersion}.patch";
|
name = "virtualbox-${finalAttrs.virtualboxVersion}-kvm-dev-${finalAttrs.kvmPatchVersion}.patch";
|
||||||
url = "https://github.com/cyberus-technology/virtualbox-kvm/releases/download/dev-${finalAttrs.kvmPatchVersion}/kvm-backend-${finalAttrs.virtualboxVersion}-dev-${finalAttrs.kvmPatchVersion}.patch";
|
url = "https://github.com/cyberus-technology/virtualbox-kvm/releases/download/dev-${finalAttrs.kvmPatchVersion}/kvm-backend-${finalAttrs.virtualboxVersion}-dev-${finalAttrs.kvmPatchVersion}.patch";
|
||||||
hash = finalAttrs.kvmPatchHash;
|
hash = finalAttrs.kvmPatchHash;
|
||||||
})
|
})
|
||||||
++ [
|
++ [
|
||||||
./qt-dependency-paths.patch
|
./qt-dependency-paths.patch
|
||||||
# https://github.com/NixOS/nixpkgs/issues/123851
|
# https://github.com/NixOS/nixpkgs/issues/123851
|
||||||
./fix-audio-driver-loading.patch
|
./fix-audio-driver-loading.patch
|
||||||
];
|
];
|
||||||
|
|
||||||
postPatch = ''
|
postPatch = ''
|
||||||
sed -i -e 's|/sbin/ifconfig|${nettools}/bin/ifconfig|' \
|
sed -i -e 's|/sbin/ifconfig|${nettools}/bin/ifconfig|' \
|
||||||
|
@ -161,18 +271,18 @@ in stdenv.mkDerivation (finalAttrs: {
|
||||||
VBOX_WITH_UPDATE_AGENT :=
|
VBOX_WITH_UPDATE_AGENT :=
|
||||||
|
|
||||||
${optionalString javaBindings ''
|
${optionalString javaBindings ''
|
||||||
VBOX_JAVA_HOME := ${jdk}
|
VBOX_JAVA_HOME := ${jdk}
|
||||||
''}
|
''}
|
||||||
${optionalString (!headless) ''
|
${optionalString (!headless) ''
|
||||||
VBOX_WITH_VBOXSDL := 1
|
VBOX_WITH_VBOXSDL := 1
|
||||||
PATH_QT5_X11_EXTRAS_LIB := ${getLib qtx11extras}/lib
|
PATH_QT5_X11_EXTRAS_LIB := ${getLib qtx11extras}/lib
|
||||||
PATH_QT5_X11_EXTRAS_INC := ${getDev qtx11extras}/include
|
PATH_QT5_X11_EXTRAS_INC := ${getDev qtx11extras}/include
|
||||||
PATH_QT5_TOOLS_LIB := ${getLib qttools}/lib
|
PATH_QT5_TOOLS_LIB := ${getLib qttools}/lib
|
||||||
PATH_QT5_TOOLS_INC := ${getDev qttools}/include
|
PATH_QT5_TOOLS_INC := ${getDev qttools}/include
|
||||||
''}
|
''}
|
||||||
${optionalString enableWebService ''
|
${optionalString enableWebService ''
|
||||||
# fix gsoap missing zlib include and produce errors with --as-needed
|
# fix gsoap missing zlib include and produce errors with --as-needed
|
||||||
VBOX_GSOAP_CXX_LIBS := gsoapssl++ z
|
VBOX_GSOAP_CXX_LIBS := gsoapssl++ z
|
||||||
''}
|
''}
|
||||||
TOOL_QT5_LRC := ${getDev qttools}/bin/lrelease
|
TOOL_QT5_LRC := ${getDev qttools}/bin/lrelease
|
||||||
LOCAL_CONFIG
|
LOCAL_CONFIG
|
||||||
|
@ -213,7 +323,9 @@ in stdenv.mkDerivation (finalAttrs: {
|
||||||
-name src -o -exec cp -avt "$libexec" {} +
|
-name src -o -exec cp -avt "$libexec" {} +
|
||||||
|
|
||||||
mkdir -p $out/bin
|
mkdir -p $out/bin
|
||||||
for file in ${optionalString (!headless) "VirtualBox VBoxSDL"} ${optionalString enableWebService "vboxwebsrv"} VBoxManage VBoxBalloonCtrl VBoxHeadless; do
|
for file in ${
|
||||||
|
optionalString (!headless) "VirtualBox VBoxSDL"
|
||||||
|
} ${optionalString enableWebService "vboxwebsrv"} VBoxManage VBoxBalloonCtrl VBoxHeadless; do
|
||||||
echo "Linking $file to /bin"
|
echo "Linking $file to /bin"
|
||||||
test -x "$libexec/$file"
|
test -x "$libexec/$file"
|
||||||
ln -s "$libexec/$file" $out/bin/$file
|
ln -s "$libexec/$file" $out/bin/$file
|
||||||
|
@ -255,15 +367,16 @@ in stdenv.mkDerivation (finalAttrs: {
|
||||||
ln -s "${finalAttrs.virtualboxGuestAdditionsIso}" "$out/share/virtualbox/VBoxGuestAdditions.iso"
|
ln -s "${finalAttrs.virtualboxGuestAdditionsIso}" "$out/share/virtualbox/VBoxGuestAdditions.iso"
|
||||||
'';
|
'';
|
||||||
|
|
||||||
preFixup = optionalString (!headless) ''
|
preFixup =
|
||||||
wrapQtApp $out/bin/VirtualBox
|
optionalString (!headless) ''
|
||||||
''
|
wrapQtApp $out/bin/VirtualBox
|
||||||
# If hardening is disabled, wrap the VirtualBoxVM binary instead of patching
|
''
|
||||||
# the source code (see postPatch).
|
# If hardening is disabled, wrap the VirtualBoxVM binary instead of patching
|
||||||
+ optionalString (!headless && !enableHardening) ''
|
# the source code (see postPatch).
|
||||||
wrapQtApp $out/libexec/virtualbox/VirtualBoxVM \
|
+ optionalString (!headless && !enableHardening) ''
|
||||||
--prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath [ vulkan-loader ]}"
|
wrapQtApp $out/libexec/virtualbox/VirtualBoxVM \
|
||||||
'';
|
--prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath [ vulkan-loader ]}"
|
||||||
|
'';
|
||||||
|
|
||||||
passthru = {
|
passthru = {
|
||||||
inherit extensionPack; # for inclusion in profile to prevent gc
|
inherit extensionPack; # for inclusion in profile to prevent gc
|
||||||
|
@ -285,7 +398,11 @@ in stdenv.mkDerivation (finalAttrs: {
|
||||||
];
|
];
|
||||||
license = lib.licenses.gpl2;
|
license = lib.licenses.gpl2;
|
||||||
homepage = "https://www.virtualbox.org/";
|
homepage = "https://www.virtualbox.org/";
|
||||||
maintainers = with lib.maintainers; [ sander friedrichaltheide blitz ];
|
maintainers = with lib.maintainers; [
|
||||||
|
sander
|
||||||
|
friedrichaltheide
|
||||||
|
blitz
|
||||||
|
];
|
||||||
platforms = [ "x86_64-linux" ];
|
platforms = [ "x86_64-linux" ];
|
||||||
mainProgram = "VirtualBox";
|
mainProgram = "VirtualBox";
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,4 +1,8 @@
|
||||||
{ fetchurl, lib, virtualbox }:
|
{
|
||||||
|
fetchurl,
|
||||||
|
lib,
|
||||||
|
virtualbox,
|
||||||
|
}:
|
||||||
let
|
let
|
||||||
inherit (virtualbox) version;
|
inherit (virtualbox) version;
|
||||||
in
|
in
|
||||||
|
@ -9,14 +13,20 @@ fetchurl rec {
|
||||||
# Manually sha256sum the extensionPack file, must be hex!
|
# Manually sha256sum the extensionPack file, must be hex!
|
||||||
# Thus do not use `nix-prefetch-url` but instead plain old `sha256sum`.
|
# Thus do not use `nix-prefetch-url` but instead plain old `sha256sum`.
|
||||||
# Checksums can also be found at https://www.virtualbox.org/download/hashes/${version}/SHA256SUMS
|
# Checksums can also be found at https://www.virtualbox.org/download/hashes/${version}/SHA256SUMS
|
||||||
let value = "d750fb17688d70e0cb2d7b06f1ad3a661303793f4d1ac39cfa9a54806b89da25";
|
let
|
||||||
in assert (builtins.stringLength value) == 64; value;
|
value = "d750fb17688d70e0cb2d7b06f1ad3a661303793f4d1ac39cfa9a54806b89da25";
|
||||||
|
in
|
||||||
|
assert (builtins.stringLength value) == 64;
|
||||||
|
value;
|
||||||
|
|
||||||
meta = with lib; {
|
meta = with lib; {
|
||||||
description = "Oracle Extension pack for VirtualBox";
|
description = "Oracle Extension pack for VirtualBox";
|
||||||
license = licenses.virtualbox-puel;
|
license = licenses.virtualbox-puel;
|
||||||
homepage = "https://www.virtualbox.org/";
|
homepage = "https://www.virtualbox.org/";
|
||||||
maintainers = with maintainers; [ sander friedrichaltheide ];
|
maintainers = with maintainers; [
|
||||||
|
sander
|
||||||
|
friedrichaltheide
|
||||||
|
];
|
||||||
platforms = [ "x86_64-linux" ];
|
platforms = [ "x86_64-linux" ];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,8 @@
|
||||||
{ fetchurl, lib, virtualbox}:
|
{
|
||||||
|
fetchurl,
|
||||||
|
lib,
|
||||||
|
virtualbox,
|
||||||
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
inherit (virtualbox) version;
|
inherit (virtualbox) version;
|
||||||
|
@ -13,7 +17,13 @@ fetchurl {
|
||||||
'';
|
'';
|
||||||
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
|
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
|
||||||
license = lib.licenses.gpl2;
|
license = lib.licenses.gpl2;
|
||||||
maintainers = [ lib.maintainers.sander lib.maintainers.friedrichaltheide ];
|
maintainers = [
|
||||||
platforms = [ "i686-linux" "x86_64-linux" ];
|
lib.maintainers.sander
|
||||||
|
lib.maintainers.friedrichaltheide
|
||||||
|
];
|
||||||
|
platforms = [
|
||||||
|
"i686-linux"
|
||||||
|
"x86_64-linux"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,32 @@
|
||||||
{ stdenv, kernel, fetchurl, lib, pam, libxslt
|
{
|
||||||
, libXext, libXcursor, libXmu
|
stdenv,
|
||||||
, glib, libXrandr, dbus, xz
|
kernel,
|
||||||
, pkg-config, which, xorg
|
fetchurl,
|
||||||
, yasm, patchelf, makeself
|
lib,
|
||||||
, linuxHeaders, openssl}:
|
pam,
|
||||||
|
libxslt,
|
||||||
|
libXext,
|
||||||
|
libXcursor,
|
||||||
|
libXmu,
|
||||||
|
glib,
|
||||||
|
libXrandr,
|
||||||
|
dbus,
|
||||||
|
xz,
|
||||||
|
pkg-config,
|
||||||
|
which,
|
||||||
|
xorg,
|
||||||
|
yasm,
|
||||||
|
patchelf,
|
||||||
|
makeself,
|
||||||
|
linuxHeaders,
|
||||||
|
openssl,
|
||||||
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
buildType = "release";
|
buildType = "release";
|
||||||
|
|
||||||
in stdenv.mkDerivation (finalAttrs: {
|
in
|
||||||
|
stdenv.mkDerivation (finalAttrs: {
|
||||||
pname = "VirtualBox-GuestAdditions-builder-${kernel.version}";
|
pname = "VirtualBox-GuestAdditions-builder-${kernel.version}";
|
||||||
version = "7.0.20";
|
version = "7.0.20";
|
||||||
|
|
||||||
|
@ -19,8 +37,26 @@ in stdenv.mkDerivation (finalAttrs: {
|
||||||
|
|
||||||
env.NIX_CFLAGS_COMPILE = "-Wno-error=incompatible-pointer-types -Wno-error=implicit-function-declaration";
|
env.NIX_CFLAGS_COMPILE = "-Wno-error=incompatible-pointer-types -Wno-error=implicit-function-declaration";
|
||||||
|
|
||||||
nativeBuildInputs = [ patchelf pkg-config which yasm makeself xorg.xorgserver openssl linuxHeaders xz ] ++ kernel.moduleBuildDependencies;
|
nativeBuildInputs = [
|
||||||
buildInputs = [ dbus libxslt libXext libXcursor pam libXmu libXrandr ];
|
patchelf
|
||||||
|
pkg-config
|
||||||
|
which
|
||||||
|
yasm
|
||||||
|
makeself
|
||||||
|
xorg.xorgserver
|
||||||
|
openssl
|
||||||
|
linuxHeaders
|
||||||
|
xz
|
||||||
|
] ++ kernel.moduleBuildDependencies;
|
||||||
|
buildInputs = [
|
||||||
|
dbus
|
||||||
|
libxslt
|
||||||
|
libXext
|
||||||
|
libXcursor
|
||||||
|
pam
|
||||||
|
libXmu
|
||||||
|
libXrandr
|
||||||
|
];
|
||||||
|
|
||||||
KERN_DIR = "${kernel.dev}/lib/modules/${kernel.modDirVersion}/build";
|
KERN_DIR = "${kernel.dev}/lib/modules/${kernel.modDirVersion}/build";
|
||||||
KERN_INCL = "${kernel.dev}/lib/modules/${kernel.modDirVersion}/source/include";
|
KERN_INCL = "${kernel.dev}/lib/modules/${kernel.modDirVersion}/source/include";
|
||||||
|
@ -58,61 +94,61 @@ in stdenv.mkDerivation (finalAttrs: {
|
||||||
'';
|
'';
|
||||||
|
|
||||||
configurePhase = ''
|
configurePhase = ''
|
||||||
NIX_CFLAGS_COMPILE=$(echo "$NIX_CFLAGS_COMPILE" | sed 's,\-isystem ${lib.getDev stdenv.cc.libc}/include,,g')
|
NIX_CFLAGS_COMPILE=$(echo "$NIX_CFLAGS_COMPILE" | sed 's,\-isystem ${lib.getDev stdenv.cc.libc}/include,,g')
|
||||||
|
|
||||||
cat >> LocalConfig.kmk <<LOCAL_CONFIG
|
cat >> LocalConfig.kmk <<LOCAL_CONFIG
|
||||||
VBOX_WITH_TESTCASES :=
|
VBOX_WITH_TESTCASES :=
|
||||||
VBOX_WITH_TESTSUITE :=
|
VBOX_WITH_TESTSUITE :=
|
||||||
VBOX_WITH_VALIDATIONKIT :=
|
VBOX_WITH_VALIDATIONKIT :=
|
||||||
VBOX_WITH_DOCS :=
|
VBOX_WITH_DOCS :=
|
||||||
VBOX_WITH_WARNINGS_AS_ERRORS :=
|
VBOX_WITH_WARNINGS_AS_ERRORS :=
|
||||||
|
|
||||||
VBOX_WITH_ORIGIN :=
|
VBOX_WITH_ORIGIN :=
|
||||||
VBOX_PATH_APP_PRIVATE_ARCH_TOP := $out/share/virtualbox
|
VBOX_PATH_APP_PRIVATE_ARCH_TOP := $out/share/virtualbox
|
||||||
VBOX_PATH_APP_PRIVATE_ARCH := $out/libexec/virtualbox
|
VBOX_PATH_APP_PRIVATE_ARCH := $out/libexec/virtualbox
|
||||||
VBOX_PATH_SHARED_LIBS := $out/libexec/virtualbox
|
VBOX_PATH_SHARED_LIBS := $out/libexec/virtualbox
|
||||||
VBOX_WITH_RUNPATH := $out/libexec/virtualbox
|
VBOX_WITH_RUNPATH := $out/libexec/virtualbox
|
||||||
VBOX_PATH_APP_PRIVATE := $out/share/virtualbox
|
VBOX_PATH_APP_PRIVATE := $out/share/virtualbox
|
||||||
VBOX_PATH_APP_DOCS := $out/doc
|
VBOX_PATH_APP_DOCS := $out/doc
|
||||||
|
|
||||||
VBOX_USE_SYSTEM_XORG_HEADERS := 1
|
VBOX_USE_SYSTEM_XORG_HEADERS := 1
|
||||||
VBOX_USE_SYSTEM_GL_HEADERS := 1
|
VBOX_USE_SYSTEM_GL_HEADERS := 1
|
||||||
VBOX_NO_LEGACY_XORG_X11 := 1
|
VBOX_NO_LEGACY_XORG_X11 := 1
|
||||||
SDK_VBoxLibPng_INCS :=
|
SDK_VBoxLibPng_INCS :=
|
||||||
SDK_VBoxLibXml2_INCS :=
|
SDK_VBoxLibXml2_INCS :=
|
||||||
SDK_VBoxLibLzma_INCS := ${xz.dev}/include
|
SDK_VBoxLibLzma_INCS := ${xz.dev}/include
|
||||||
SDK_VBoxLibLzma_LIBS := ${xz.out}/lib
|
SDK_VBoxLibLzma_LIBS := ${xz.out}/lib
|
||||||
|
|
||||||
SDK_VBoxOpenSslStatic_INCS := ${openssl.dev}/include/ssl
|
SDK_VBoxOpenSslStatic_INCS := ${openssl.dev}/include/ssl
|
||||||
|
|
||||||
VBOX_ONLY_ADDITIONS := 1
|
VBOX_ONLY_ADDITIONS := 1
|
||||||
VBOX_WITH_SHARED_CLIPBOARD := 1
|
VBOX_WITH_SHARED_CLIPBOARD := 1
|
||||||
VBOX_WITH_GUEST_PROPS := 1
|
VBOX_WITH_GUEST_PROPS := 1
|
||||||
VBOX_WITH_VMSVGA := 1
|
VBOX_WITH_VMSVGA := 1
|
||||||
VBOX_WITH_SHARED_FOLDERS := 1
|
VBOX_WITH_SHARED_FOLDERS := 1
|
||||||
VBOX_WITH_GUEST_CONTROL := 1
|
VBOX_WITH_GUEST_CONTROL := 1
|
||||||
VBOX_WITHOUT_LINUX_GUEST_PACKAGE := 1
|
VBOX_WITHOUT_LINUX_GUEST_PACKAGE := 1
|
||||||
VBOX_WITH_PAM :=
|
VBOX_WITH_PAM :=
|
||||||
VBOX_WITH_UPDATE_AGENT :=
|
VBOX_WITH_UPDATE_AGENT :=
|
||||||
VBOX_WITH_AUDIO_ALSA :=
|
VBOX_WITH_AUDIO_ALSA :=
|
||||||
VBOX_WITH_AUDIO_PULSE :=
|
VBOX_WITH_AUDIO_PULSE :=
|
||||||
|
|
||||||
VBOX_BUILD_PUBLISHER := _NixOS
|
VBOX_BUILD_PUBLISHER := _NixOS
|
||||||
LOCAL_CONFIG
|
LOCAL_CONFIG
|
||||||
|
|
||||||
./configure \
|
./configure \
|
||||||
--only-additions \
|
--only-additions \
|
||||||
--with-linux=${kernel.dev} \
|
--with-linux=${kernel.dev} \
|
||||||
--disable-kmods
|
--disable-kmods
|
||||||
|
|
||||||
sed -e 's@PKG_CONFIG_PATH=.*@PKG_CONFIG_PATH=${glib.dev}/lib/pkgconfig @' \
|
sed -e 's@PKG_CONFIG_PATH=.*@PKG_CONFIG_PATH=${glib.dev}/lib/pkgconfig @' \
|
||||||
-i AutoConfig.kmk
|
-i AutoConfig.kmk
|
||||||
sed -e 's@arch/x86/@@' \
|
sed -e 's@arch/x86/@@' \
|
||||||
-i Config.kmk
|
-i Config.kmk
|
||||||
|
|
||||||
export USER=nix
|
export USER=nix
|
||||||
set +x
|
set +x
|
||||||
'';
|
'';
|
||||||
|
|
||||||
enableParallelBuilding = true;
|
enableParallelBuilding = true;
|
||||||
|
|
||||||
|
@ -130,7 +166,11 @@ in stdenv.mkDerivation (finalAttrs: {
|
||||||
runHook preInstall
|
runHook preInstall
|
||||||
|
|
||||||
mkdir -p $out
|
mkdir -p $out
|
||||||
cp -rv ./out/linux.${if stdenv.hostPlatform.is32bit then "x86" else "amd64"}/${buildType}/bin/additions/VBoxGuestAdditions-${if stdenv.hostPlatform.is32bit then "x86" else "amd64"}.tar.bz2 $out/
|
cp -rv ./out/linux.${
|
||||||
|
if stdenv.hostPlatform.is32bit then "x86" else "amd64"
|
||||||
|
}/${buildType}/bin/additions/VBoxGuestAdditions-${
|
||||||
|
if stdenv.hostPlatform.is32bit then "x86" else "amd64"
|
||||||
|
}.tar.bz2 $out/
|
||||||
|
|
||||||
runHook postInstall
|
runHook postInstall
|
||||||
'';
|
'';
|
||||||
|
|
|
@ -1,5 +1,13 @@
|
||||||
{ stdenv, kernel, callPackage, lib, dbus
|
{
|
||||||
, xorg, zlib, patchelf, makeWrapper
|
stdenv,
|
||||||
|
kernel,
|
||||||
|
callPackage,
|
||||||
|
lib,
|
||||||
|
dbus,
|
||||||
|
xorg,
|
||||||
|
zlib,
|
||||||
|
patchelf,
|
||||||
|
makeWrapper,
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
virtualBoxNixGuestAdditionsBuilder = callPackage ./builder.nix { };
|
virtualBoxNixGuestAdditionsBuilder = callPackage ./builder.nix { };
|
||||||
|
@ -12,96 +20,129 @@ let
|
||||||
# dlopen are found. We grep binaries for specific library names and patch
|
# dlopen are found. We grep binaries for specific library names and patch
|
||||||
# RUNPATH in matching binaries to contain the needed library paths.
|
# RUNPATH in matching binaries to contain the needed library paths.
|
||||||
dlopenLibs = [
|
dlopenLibs = [
|
||||||
{ name = "libdbus-1.so"; pkg = dbus; }
|
{
|
||||||
{ name = "libXfixes.so"; pkg = xorg.libXfixes; }
|
name = "libdbus-1.so";
|
||||||
{ name = "libXrandr.so"; pkg = xorg.libXrandr; }
|
pkg = dbus;
|
||||||
|
}
|
||||||
|
{
|
||||||
|
name = "libXfixes.so";
|
||||||
|
pkg = xorg.libXfixes;
|
||||||
|
}
|
||||||
|
{
|
||||||
|
name = "libXrandr.so";
|
||||||
|
pkg = xorg.libXrandr;
|
||||||
|
}
|
||||||
];
|
];
|
||||||
in stdenv.mkDerivation {
|
in
|
||||||
pname = "VirtualBox-GuestAdditions";
|
stdenv.mkDerivation {
|
||||||
version = "${virtualBoxNixGuestAdditionsBuilder.version}-${kernel.version}";
|
pname = "VirtualBox-GuestAdditions";
|
||||||
|
version = "${virtualBoxNixGuestAdditionsBuilder.version}-${kernel.version}";
|
||||||
|
|
||||||
src = "${virtualBoxNixGuestAdditionsBuilder}/VBoxGuestAdditions-${if stdenv.hostPlatform.is32bit then "x86" else "amd64"}.tar.bz2";
|
src = "${virtualBoxNixGuestAdditionsBuilder}/VBoxGuestAdditions-${
|
||||||
sourceRoot = ".";
|
if stdenv.hostPlatform.is32bit then "x86" else "amd64"
|
||||||
|
}.tar.bz2";
|
||||||
|
sourceRoot = ".";
|
||||||
|
|
||||||
KERN_DIR = "${kernel.dev}/lib/modules/${kernel.modDirVersion}/build";
|
KERN_DIR = "${kernel.dev}/lib/modules/${kernel.modDirVersion}/build";
|
||||||
KERN_INCL = "${kernel.dev}/lib/modules/${kernel.modDirVersion}/source/include";
|
KERN_INCL = "${kernel.dev}/lib/modules/${kernel.modDirVersion}/source/include";
|
||||||
|
|
||||||
hardeningDisable = [ "pic" ];
|
hardeningDisable = [ "pic" ];
|
||||||
|
|
||||||
env.NIX_CFLAGS_COMPILE = "-Wno-error=incompatible-pointer-types -Wno-error=implicit-function-declaration";
|
env.NIX_CFLAGS_COMPILE = "-Wno-error=incompatible-pointer-types -Wno-error=implicit-function-declaration";
|
||||||
|
|
||||||
nativeBuildInputs = [ patchelf makeWrapper virtualBoxNixGuestAdditionsBuilder ] ++ kernel.moduleBuildDependencies;
|
nativeBuildInputs = [
|
||||||
|
patchelf
|
||||||
|
makeWrapper
|
||||||
|
virtualBoxNixGuestAdditionsBuilder
|
||||||
|
] ++ kernel.moduleBuildDependencies;
|
||||||
|
|
||||||
buildPhase = ''
|
buildPhase = ''
|
||||||
runHook preBuild
|
runHook preBuild
|
||||||
|
|
||||||
# Build kernel modules.
|
# Build kernel modules.
|
||||||
cd src/vboxguest-${virtualBoxNixGuestAdditionsBuilder.version}_NixOS
|
cd src/vboxguest-${virtualBoxNixGuestAdditionsBuilder.version}_NixOS
|
||||||
# Run just make first. If we only did make install, we get symbol warnings during build.
|
# Run just make first. If we only did make install, we get symbol warnings during build.
|
||||||
make
|
make
|
||||||
cd ../..
|
cd ../..
|
||||||
|
|
||||||
# Change the interpreter for various binaries
|
# Change the interpreter for various binaries
|
||||||
for i in sbin/VBoxService bin/{VBoxClient,VBoxControl,VBoxDRMClient} other/mount.vboxsf; do
|
for i in sbin/VBoxService bin/{VBoxClient,VBoxControl,VBoxDRMClient} other/mount.vboxsf; do
|
||||||
patchelf --set-interpreter ${stdenv.cc.bintools.dynamicLinker} $i
|
patchelf --set-interpreter ${stdenv.cc.bintools.dynamicLinker} $i
|
||||||
patchelf --set-rpath ${lib.makeLibraryPath [ stdenv.cc.cc stdenv.cc.libc zlib
|
patchelf --set-rpath ${
|
||||||
xorg.libX11 xorg.libXt xorg.libXext xorg.libXmu xorg.libXfixes xorg.libXcursor ]} $i
|
lib.makeLibraryPath [
|
||||||
done
|
stdenv.cc.cc
|
||||||
|
stdenv.cc.libc
|
||||||
|
zlib
|
||||||
|
xorg.libX11
|
||||||
|
xorg.libXt
|
||||||
|
xorg.libXext
|
||||||
|
xorg.libXmu
|
||||||
|
xorg.libXfixes
|
||||||
|
xorg.libXcursor
|
||||||
|
]
|
||||||
|
} $i
|
||||||
|
done
|
||||||
|
|
||||||
runHook postBuild
|
runHook postBuild
|
||||||
|
'';
|
||||||
|
|
||||||
|
installPhase = ''
|
||||||
|
runHook preInstall
|
||||||
|
|
||||||
|
mkdir -p $out/bin
|
||||||
|
|
||||||
|
# Install kernel modules.
|
||||||
|
cd src/vboxguest-${virtualBoxNixGuestAdditionsBuilder.version}_NixOS
|
||||||
|
make install INSTALL_MOD_PATH=$out KBUILD_EXTRA_SYMBOLS=$PWD/vboxsf/Module.symvers
|
||||||
|
cd ../..
|
||||||
|
|
||||||
|
# Install binaries
|
||||||
|
install -D -m 755 other/mount.vboxsf $out/bin/mount.vboxsf
|
||||||
|
install -D -m 755 sbin/VBoxService $out/bin/VBoxService
|
||||||
|
|
||||||
|
install -m 755 bin/VBoxClient $out/bin
|
||||||
|
install -m 755 bin/VBoxControl $out/bin
|
||||||
|
install -m 755 bin/VBoxDRMClient $out/bin
|
||||||
|
|
||||||
|
|
||||||
|
# Don't install VBoxOGL for now
|
||||||
|
# It seems to be broken upstream too, and fixing it is far down the priority list:
|
||||||
|
# https://www.virtualbox.org/pipermail/vbox-dev/2017-June/014561.html
|
||||||
|
# Additionally, 3d support seems to rely on VBoxOGL.so being symlinked from
|
||||||
|
# libGL.so (which we can't), and Oracle doesn't plan on supporting libglvnd
|
||||||
|
# either. (#18457)
|
||||||
|
|
||||||
|
runHook postInstall
|
||||||
|
'';
|
||||||
|
|
||||||
|
# Stripping breaks these binaries for some reason.
|
||||||
|
dontStrip = true;
|
||||||
|
|
||||||
|
# Patch RUNPATH according to dlopenLibs (see the comment there).
|
||||||
|
postFixup = lib.concatMapStrings (library: ''
|
||||||
|
for i in $(grep -F ${lib.escapeShellArg library.name} -l -r $out/{lib,bin}); do
|
||||||
|
origRpath=$(patchelf --print-rpath "$i")
|
||||||
|
patchelf --set-rpath "$origRpath:${lib.makeLibraryPath [ library.pkg ]}" "$i"
|
||||||
|
done
|
||||||
|
'') dlopenLibs;
|
||||||
|
|
||||||
|
meta = {
|
||||||
|
description = "Guest additions for VirtualBox";
|
||||||
|
longDescription = ''
|
||||||
|
Various add-ons which makes NixOS work better as guest OS inside VirtualBox.
|
||||||
|
This add-on provides support for dynamic resizing of the virtual display, shared
|
||||||
|
host/guest clipboard support.
|
||||||
'';
|
'';
|
||||||
|
sourceProvenance = with lib.sourceTypes; [ fromSource ];
|
||||||
installPhase = ''
|
license = lib.licenses.gpl2;
|
||||||
runHook preInstall
|
maintainers = [
|
||||||
|
lib.maintainers.sander
|
||||||
mkdir -p $out/bin
|
lib.maintainers.friedrichaltheide
|
||||||
|
];
|
||||||
# Install kernel modules.
|
platforms = [
|
||||||
cd src/vboxguest-${virtualBoxNixGuestAdditionsBuilder.version}_NixOS
|
"i686-linux"
|
||||||
make install INSTALL_MOD_PATH=$out KBUILD_EXTRA_SYMBOLS=$PWD/vboxsf/Module.symvers
|
"x86_64-linux"
|
||||||
cd ../..
|
];
|
||||||
|
broken = stdenv.hostPlatform.is32bit && (kernel.kernelAtLeast "5.10");
|
||||||
# Install binaries
|
};
|
||||||
install -D -m 755 other/mount.vboxsf $out/bin/mount.vboxsf
|
}
|
||||||
install -D -m 755 sbin/VBoxService $out/bin/VBoxService
|
|
||||||
|
|
||||||
install -m 755 bin/VBoxClient $out/bin
|
|
||||||
install -m 755 bin/VBoxControl $out/bin
|
|
||||||
install -m 755 bin/VBoxDRMClient $out/bin
|
|
||||||
|
|
||||||
|
|
||||||
# Don't install VBoxOGL for now
|
|
||||||
# It seems to be broken upstream too, and fixing it is far down the priority list:
|
|
||||||
# https://www.virtualbox.org/pipermail/vbox-dev/2017-June/014561.html
|
|
||||||
# Additionally, 3d support seems to rely on VBoxOGL.so being symlinked from
|
|
||||||
# libGL.so (which we can't), and Oracle doesn't plan on supporting libglvnd
|
|
||||||
# either. (#18457)
|
|
||||||
|
|
||||||
runHook postInstall
|
|
||||||
'';
|
|
||||||
|
|
||||||
# Stripping breaks these binaries for some reason.
|
|
||||||
dontStrip = true;
|
|
||||||
|
|
||||||
# Patch RUNPATH according to dlopenLibs (see the comment there).
|
|
||||||
postFixup = lib.concatMapStrings (library: ''
|
|
||||||
for i in $(grep -F ${lib.escapeShellArg library.name} -l -r $out/{lib,bin}); do
|
|
||||||
origRpath=$(patchelf --print-rpath "$i")
|
|
||||||
patchelf --set-rpath "$origRpath:${lib.makeLibraryPath [ library.pkg ]}" "$i"
|
|
||||||
done
|
|
||||||
'') dlopenLibs;
|
|
||||||
|
|
||||||
meta = {
|
|
||||||
description = "Guest additions for VirtualBox";
|
|
||||||
longDescription = ''
|
|
||||||
Various add-ons which makes NixOS work better as guest OS inside VirtualBox.
|
|
||||||
This add-on provides support for dynamic resizing of the virtual display, shared
|
|
||||||
host/guest clipboard support.
|
|
||||||
'';
|
|
||||||
sourceProvenance = with lib.sourceTypes; [ fromSource ];
|
|
||||||
license = lib.licenses.gpl2;
|
|
||||||
maintainers = [ lib.maintainers.sander lib.maintainers.friedrichaltheide ];
|
|
||||||
platforms = [ "i686-linux" "x86_64-linux" ];
|
|
||||||
broken = stdenv.hostPlatform.is32bit && (kernel.kernelAtLeast "5.10");
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue