Unverified Commit c792c60b authored by Friedrich Altheide's avatar Friedrich Altheide Committed by GitHub
Browse files

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
parent 2490a12c
Loading
Loading
Loading
Loading
+34 −11
Original line number Diff line number Diff line
@@ -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" ];
@@ -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 = [
@@ -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
@@ -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";

@@ -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;
      })
    ]
  );
+14 −4
Original line number Diff line number Diff line
@@ -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.
@@ -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 {