virtualboxGuestAdditions: Additional 7.1.4 fixes (#366080)

* virtualboxGuestAddtitions: Load required dynamic libs

* virtualboxGuestAdditions: Remove unused code

* virtualboxGuestAdditions: introduce verbose logging option

* virtualboxGuestAdditions: only load vboxsf if enabled in module options

Changed files
+48 -15
nixos
modules
virtualisation
pkgs
applications
virtualization
virtualbox
guest-additions
+34 -11
nixos/modules/virtualisation/virtualbox-guest.nix
···
cfg = config.virtualisation.virtualbox.guest;
kernel = config.boot.kernelPackages;
-
mkVirtualBoxUserService = serviceArgs: {
description = "VirtualBox Guest User Services ${serviceArgs}";
wantedBy = [ "graphical-session.target" ];
···
# Check if the display environment is ready, otherwise fail
preStart = "${pkgs.bash}/bin/bash -c \"if [ -z $DISPLAY ]; then exit 1; fi\"";
serviceConfig = {
-
ExecStart = "@${kernel.virtualboxGuestAdditions}/bin/VBoxClient --foreground ${serviceArgs}";
# Wait after a failure, hoping that the display environment is ready after waiting
RestartSec = 2;
Restart = "always";
};
};
in
{
imports = [
···
type = lib.types.bool;
description = "Whether to enable drag and drop support.";
};
};
###### implementation
···
boot.extraModulePackages = [ kernel.virtualboxGuestAdditions ];
-
boot.supportedFilesystems = [ "vboxsf" ];
-
boot.initrd.supportedFilesystems = [ "vboxsf" ];
-
-
users.groups.vboxsf.gid = config.ids.gids.vboxsf;
-
systemd.services.virtualbox = {
description = "VirtualBox Guest Services";
···
SUBSYSTEM=="misc", KERNEL=="vboxguest", TAG+="systemd"
'';
-
systemd.user.services.virtualboxClientVmsvga = mkVirtualBoxUserService "--vmsvga-session";
}
(lib.mkIf cfg.clipboard {
-
systemd.user.services.virtualboxClientClipboard = mkVirtualBoxUserService "--clipboard";
})
(lib.mkIf cfg.seamless {
-
systemd.user.services.virtualboxClientSeamless = mkVirtualBoxUserService "--seamless";
})
(lib.mkIf cfg.dragAndDrop {
-
systemd.user.services.virtualboxClientDragAndDrop = mkVirtualBoxUserService "--draganddrop";
})
]
);
···
cfg = config.virtualisation.virtualbox.guest;
kernel = config.boot.kernelPackages;
+
mkVirtualBoxUserService = serviceArgs: verbose: {
description = "VirtualBox Guest User Services ${serviceArgs}";
wantedBy = [ "graphical-session.target" ];
···
# Check if the display environment is ready, otherwise fail
preStart = "${pkgs.bash}/bin/bash -c \"if [ -z $DISPLAY ]; then exit 1; fi\"";
serviceConfig = {
+
ExecStart =
+
"@${kernel.virtualboxGuestAdditions}/bin/VBoxClient"
+
+ (lib.strings.optionalString verbose " --verbose")
+
+ " --foreground ${serviceArgs}";
# Wait after a failure, hoping that the display environment is ready after waiting
RestartSec = 2;
Restart = "always";
};
};
+
+
mkVirtualBoxUserX11OnlyService =
+
serviceArgs: verbose:
+
(mkVirtualBoxUserService serviceArgs verbose)
+
// {
+
unitConfig.ConditionEnvironment = "XDG_SESSION_TYPE=x11";
+
};
in
{
imports = [
···
type = lib.types.bool;
description = "Whether to enable drag and drop support.";
};
+
+
verbose = lib.mkOption {
+
default = false;
+
type = lib.types.bool;
+
description = "Whether to verbose logging for guest services.";
+
};
+
+
vboxsf = lib.mkOption {
+
default = true;
+
type = lib.types.bool;
+
description = "Whether to load vboxsf";
+
};
};
###### implementation
···
boot.extraModulePackages = [ kernel.virtualboxGuestAdditions ];
systemd.services.virtualbox = {
description = "VirtualBox Guest Services";
···
SUBSYSTEM=="misc", KERNEL=="vboxguest", TAG+="systemd"
'';
+
systemd.user.services.virtualboxClientVmsvga = mkVirtualBoxUserService "--vmsvga-session" cfg.verbose;
}
+
(lib.mkIf cfg.vboxsf {
+
boot.supportedFilesystems = [ "vboxsf" ];
+
boot.initrd.supportedFilesystems = [ "vboxsf" ];
+
+
users.groups.vboxsf.gid = config.ids.gids.vboxsf;
+
})
(lib.mkIf cfg.clipboard {
+
systemd.user.services.virtualboxClientClipboard = mkVirtualBoxUserService "--clipboard" cfg.verbose;
})
(lib.mkIf cfg.seamless {
+
systemd.user.services.virtualboxClientSeamless = mkVirtualBoxUserX11OnlyService "--seamless" cfg.verbose;
})
(lib.mkIf cfg.dragAndDrop {
+
systemd.user.services.virtualboxClientDragAndDrop = mkVirtualBoxUserService "--draganddrop" cfg.verbose;
})
]
);
+14 -4
pkgs/applications/virtualization/virtualbox/guest-additions/default.nix
···
zlib,
patchelf,
makeWrapper,
}:
let
virtualBoxNixGuestAdditionsBuilder = callPackage ./builder.nix { };
-
-
# Forced to 1.18; vboxvideo doesn't seem to provide any newer ABI,
-
# and nixpkgs doesn't support older ABIs anymore.
-
xserverABI = "118";
# Specifies how to patch binaries to make sure that libraries loaded using
# dlopen are found. We grep binaries for specific library names and patch
···
{
name = "libXrandr.so";
pkg = xorg.libXrandr;
}
];
in
···
zlib,
patchelf,
makeWrapper,
+
wayland,
+
libX11,
}:
let
virtualBoxNixGuestAdditionsBuilder = callPackage ./builder.nix { };
# Specifies how to patch binaries to make sure that libraries loaded using
# dlopen are found. We grep binaries for specific library names and patch
···
{
name = "libXrandr.so";
pkg = xorg.libXrandr;
+
}
+
{
+
name = "libwayland-client.so";
+
pkg = wayland;
+
}
+
{
+
name = "libX11.so";
+
pkg = libX11;
+
}
+
{
+
name = "libXt.so";
+
pkg = xorg.libXt;
}
];
in