Skip to content

Commit

Permalink
virtualboxGuestAdditions: Additional 7.1.4 fixes (#366080)
Browse files Browse the repository at this point in the history
* virtualboxGuestAddtitions: Load required dynamic libs

* virtualboxGuestAdditions: Remove unused code

* virtualboxGuestAdditions: introduce verbose logging option

* virtualboxGuestAdditions: only load vboxsf if enabled in module options
  • Loading branch information
FriedrichAltheide authored Dec 25, 2024
1 parent 2490a12 commit c792c60
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 15 deletions.
45 changes: 34 additions & 11 deletions nixos/modules/virtualisation/virtualbox-guest.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ let
cfg = config.virtualisation.virtualbox.guest;
kernel = config.boot.kernelPackages;

mkVirtualBoxUserService = serviceArgs: {
mkVirtualBoxUserService = serviceArgs: verbose: {
description = "VirtualBox Guest User Services ${serviceArgs}";

wantedBy = [ "graphical-session.target" ];
Expand All @@ -24,12 +24,22 @@ let
# 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}";
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 = [
Expand Down Expand Up @@ -73,6 +83,18 @@ in
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
Expand All @@ -91,11 +113,6 @@ in

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";

Expand All @@ -117,16 +134,22 @@ in
SUBSYSTEM=="misc", KERNEL=="vboxguest", TAG+="systemd"
'';

systemd.user.services.virtualboxClientVmsvga = mkVirtualBoxUserService "--vmsvga-session";
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";
systemd.user.services.virtualboxClientClipboard = mkVirtualBoxUserService "--clipboard" cfg.verbose;
})
(lib.mkIf cfg.seamless {
systemd.user.services.virtualboxClientSeamless = mkVirtualBoxUserService "--seamless";
systemd.user.services.virtualboxClientSeamless = mkVirtualBoxUserX11OnlyService "--seamless" cfg.verbose;
})
(lib.mkIf cfg.dragAndDrop {
systemd.user.services.virtualboxClientDragAndDrop = mkVirtualBoxUserService "--draganddrop";
systemd.user.services.virtualboxClientDragAndDrop = mkVirtualBoxUserService "--draganddrop" cfg.verbose;
})
]
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@
zlib,
patchelf,
makeWrapper,
wayland,
libX11,
}:
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
# RUNPATH in matching binaries to contain the needed library paths.
Expand All @@ -32,6 +30,18 @@ let
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 {
Expand Down

0 comments on commit c792c60

Please sign in to comment.