push sheeet
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s

This commit is contained in:
Dark Steveneq
2025-10-09 14:15:47 +02:00
commit 646b892680
49168 changed files with 5897842 additions and 0 deletions

View File

@@ -0,0 +1,173 @@
{
stdenv,
kernel,
fetchurl,
lib,
pam,
libxslt,
libXext,
libXcursor,
libXmu,
glib,
libXrandr,
dbus,
xz,
pkg-config,
which,
xorg,
yasm,
patchelf,
makeself,
linuxHeaders,
openssl,
virtualboxVersion,
virtualboxSubVersion,
virtualboxSha256,
platform,
}:
let
buildType = "release";
in
stdenv.mkDerivation (finalAttrs: {
pname = "VirtualBox-GuestAdditions-builder-${kernel.version}";
version = "${virtualboxVersion}${virtualboxSubVersion}";
inherit virtualboxVersion virtualboxSubVersion;
src = fetchurl {
url = "https://download.virtualbox.org/virtualbox/${finalAttrs.virtualboxVersion}/VirtualBox-${finalAttrs.virtualboxVersion}${finalAttrs.virtualboxSubVersion}.tar.bz2";
sha256 = virtualboxSha256;
};
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;
buildInputs = [
dbus
libxslt
libXext
libXcursor
pam
libXmu
libXrandr
];
KERN_DIR = "${kernel.dev}/lib/modules/${kernel.modDirVersion}/build";
KERN_INCL = "${kernel.dev}/lib/modules/${kernel.modDirVersion}/source/include";
prePatch = ''
rm -r src/VBox/Additions/x11/x11include/
rm -r src/VBox/Additions/3D/mesa/mesa-*/
rm -r src/libs/openssl-*/
rm -r src/libs/curl-*/
rm -r src/libs/libpng-*/
rm -r src/libs/libxml2-*/
rm -r src/libs/liblzma-*/
rm -r src/libs/zlib*/
'';
postPatch = ''
set -x
sed -e 's@MKISOFS --version@MKISOFS -version@' \
-e 's@CXX_FLAGS="\(.*\)"@CXX_FLAGS="-std=c++17 \1"@' \
-i configure
ls kBuild/bin/linux.${platform}/k* tools/linux.${platform}/bin/* | xargs -n 1 patchelf --set-interpreter ${stdenv.cc.bintools.dynamicLinker}
substituteInPlace ./include/VBox/dbus-calls.h --replace-fail libdbus-1.so.3 ${dbus.lib}/lib/libdbus-1.so.3
substituteInPlace ./src/VBox/Additions/common/VBoxGuest/lib/VBoxGuestR3LibDrmClient.cpp --replace-fail /usr/bin/VBoxDRMClient /run/current-system/sw/bin/VBoxDRMClient
substituteInPlace ./src/VBox/Additions/common/VBoxGuest/lib/VBoxGuestR3LibDrmClient.cpp --replace-fail /usr/bin/VBoxClient /run/current-system/sw/bin/VBoxClient
substituteInPlace ./src/VBox/Additions/x11/VBoxClient/display.cpp --replace-fail /usr/X11/bin/xrandr ${xorg.xrandr}/bin/xrandr
substituteInPlace ./src/VBox/Additions/x11/vboxvideo/Makefile.kmk --replace-fail /usr/include/xorg "${xorg.xorgserver.dev}/include/xorg "
'';
configurePhase = ''
NIX_CFLAGS_COMPILE=$(echo "$NIX_CFLAGS_COMPILE" | sed 's,\-isystem ${lib.getDev stdenv.cc.libc}/include,,g')
cat >> LocalConfig.kmk <<LOCAL_CONFIG
VBOX_WITH_TESTCASES :=
VBOX_WITH_TESTSUITE :=
VBOX_WITH_VALIDATIONKIT :=
VBOX_WITH_DOCS :=
VBOX_WITH_WARNINGS_AS_ERRORS :=
VBOX_WITH_ORIGIN :=
VBOX_PATH_APP_PRIVATE_ARCH_TOP := $out/share/virtualbox
VBOX_PATH_APP_PRIVATE_ARCH := $out/libexec/virtualbox
VBOX_PATH_SHARED_LIBS := $out/libexec/virtualbox
VBOX_WITH_RUNPATH := $out/libexec/virtualbox
VBOX_PATH_APP_PRIVATE := $out/share/virtualbox
VBOX_PATH_APP_DOCS := $out/doc
VBOX_USE_SYSTEM_XORG_HEADERS := 1
VBOX_USE_SYSTEM_GL_HEADERS := 1
VBOX_NO_LEGACY_XORG_X11 := 1
SDK_VBoxLibPng_INCS :=
SDK_VBoxLibXml2_INCS :=
SDK_VBoxLibLzma_INCS := ${xz.dev}/include
SDK_VBoxLibLzma_LIBS := ${xz.out}/lib
SDK_VBoxOpenSslStatic_INCS := ${openssl.dev}/include/ssl
VBOX_ONLY_ADDITIONS := 1
VBOX_WITH_SHARED_CLIPBOARD := 1
VBOX_WITH_GUEST_PROPS := 1
VBOX_WITH_VMSVGA := 1
VBOX_WITH_SHARED_FOLDERS := 1
VBOX_WITH_GUEST_CONTROL := 1
VBOX_WITHOUT_LINUX_GUEST_PACKAGE := 1
VBOX_WITH_PAM :=
VBOX_WITH_UPDATE_AGENT :=
VBOX_WITH_AUDIO_ALSA :=
VBOX_WITH_AUDIO_PULSE :=
VBOX_BUILD_PUBLISHER := _NixOS
LOCAL_CONFIG
./configure \
--only-additions \
--with-linux=${kernel.dev} \
--disable-kmods
sed -e 's@PKG_CONFIG_PATH=.*@PKG_CONFIG_PATH=${glib.dev}/lib/pkgconfig @' \
-i AutoConfig.kmk
sed -e 's@arch/x86/@@' \
-i Config.kmk
export USER=nix
set +x
'';
enableParallelBuilding = true;
buildPhase = ''
runHook preBuild
source env.sh
VBOX_ONLY_ADDITIONS=1 VBOX_ONLY_BUILD=1 kmk -j $NIX_BUILD_CORES BUILD_TYPE="${buildType}"
VBOX_ONLY_ADDITIONS=1 VBOX_ONLY_BUILD=1 kmk packing
runHook postBuild
'';
installPhase = ''
runHook preInstall
mkdir -p $out
cp -rv ./out/linux.${platform}/${buildType}/bin/additions/VBoxGuestAdditions-${platform}.tar.bz2 $out/
runHook postInstall
'';
})

View File

@@ -0,0 +1,177 @@
{
stdenv,
kernel,
callPackage,
lib,
dbus,
xorg,
zlib,
patchelf,
makeWrapper,
wayland,
libX11,
}:
let
virtualboxVersion = "7.2.0";
virtualboxSubVersion = "";
virtualboxSha256 = "4f2804ff27848ea772aee6b637bb1e10ee74ec2da117c257413e2d2c4f670ba0";
platform =
if stdenv.hostPlatform.isAarch64 then
"arm64"
else if stdenv.hostPlatform.is32bit then
"x86"
else
"amd64";
virtualBoxNixGuestAdditionsBuilder = callPackage ./builder.nix {
inherit
virtualboxVersion
virtualboxSubVersion
virtualboxSha256
platform
;
};
# Specifies how to patch binaries to make sure that libraries loaded using
# dlopen are found. We grep binaries for specific library names and patch
# RUNPATH in matching binaries to contain the needed library paths.
dlopenLibs = [
{
name = "libdbus-1.so";
pkg = dbus;
}
{
name = "libXfixes.so";
pkg = xorg.libXfixes;
}
{
name = "libXrandr.so";
pkg = xorg.libXrandr;
}
{
name = "libwayland-client.so";
pkg = wayland;
}
{
name = "libX11.so";
pkg = libX11;
}
{
name = "libXt.so";
pkg = xorg.libXt;
}
];
in
stdenv.mkDerivation {
pname = "VirtualBox-GuestAdditions";
version = "${virtualboxVersion}${virtualboxSubVersion}-${kernel.version}";
src = "${virtualBoxNixGuestAdditionsBuilder}/VBoxGuestAdditions-${platform}.tar.bz2";
sourceRoot = ".";
KERN_DIR = "${kernel.dev}/lib/modules/${kernel.modDirVersion}/build";
KERN_INCL = "${kernel.dev}/lib/modules/${kernel.modDirVersion}/source/include";
hardeningDisable = [ "pic" ];
env.NIX_CFLAGS_COMPILE = "-Wno-error=incompatible-pointer-types -Wno-error=implicit-function-declaration";
nativeBuildInputs = [
patchelf
makeWrapper
virtualBoxNixGuestAdditionsBuilder
]
++ kernel.moduleBuildDependencies;
buildPhase = ''
runHook preBuild
# Build kernel modules.
cd src/vboxguest-${virtualboxVersion}_NixOS
# Run just make first. If we only did make install, we get symbol warnings during build.
make
cd ../..
# Change the interpreter for various binaries
for i in sbin/VBoxService bin/{VBoxClient,VBoxControl,VBoxDRMClient} other/mount.vboxsf; do
patchelf --set-interpreter ${stdenv.cc.bintools.dynamicLinker} $i
patchelf --set-rpath ${
lib.makeLibraryPath [
stdenv.cc.cc
stdenv.cc.libc
zlib
xorg.libX11
xorg.libXt
xorg.libXext
xorg.libXmu
xorg.libXfixes
xorg.libXcursor
]
} $i
done
runHook postBuild
'';
installPhase = ''
runHook preInstall
mkdir -p $out/bin
# Install kernel modules.
cd src/vboxguest-${virtualboxVersion}_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 ];
license = lib.licenses.gpl3Only;
maintainers = [
lib.maintainers.sander
lib.maintainers.friedrichaltheide
];
platforms = [
"i686-linux"
"x86_64-linux"
"aarch64-linux"
];
broken = stdenv.hostPlatform.is32bit && (kernel.kernelAtLeast "5.10");
};
}