Unverified Commit 7f224715 authored by John Ericson's avatar John Ericson Committed by GitHub
Browse files

wine: Inline `supportFlags` in `base.nix` (#487848)

parents 1a6618ff 5c02baae
Loading
Loading
Loading
Loading
+60 −32
Original line number Diff line number Diff line
@@ -17,13 +17,13 @@
  makeWrapper,
  pkg-config,
  nixosTests,
  supportFlags,
  pnameSuffix ? "",
  patches,
  moltenvk,
  buildScript ? null,
  configureFlags ? [ ],
  mainProgram ? "wine",

  # Staging support
  useStaging ? false,
  autoconf,
@@ -31,6 +31,39 @@
  perl,
  python3,
  gitMinimal,

  # Support flags
  gettextSupport ? false,
  fontconfigSupport ? false,
  alsaSupport ? false,
  gtkSupport ? false,
  openglSupport ? false,
  tlsSupport ? false,
  gstreamerSupport ? false,
  cupsSupport ? false,
  dbusSupport ? false,
  openclSupport ? false,
  cairoSupport ? false,
  odbcSupport ? false,
  netapiSupport ? false,
  cursesSupport ? false,
  vaSupport ? false,
  pcapSupport ? false,
  v4lSupport ? false,
  saneSupport ? false,
  gphoto2Support ? false,
  krb5Support ? false,
  pulseaudioSupport ? false,
  udevSupport ? false,
  xineramaSupport ? false,
  vulkanSupport ? false,
  sdlSupport ? false,
  usbSupport ? false,
  mingwSupport ? stdenv.hostPlatform.isDarwin,
  waylandSupport ? false,
  x11Support ? false,
  ffmpegSupport ? false,
  embedInstallers ? false,
}:

let
@@ -47,26 +80,23 @@ let
    };
  } ./setup-hook-darwin.sh;

  # Building Wine with these flags isnt supported on Darwin. Using any of them will result in an evaluation failures
  # Building Wine with these flags isn't supported on Darwin. Using any of them will result in an evaluation failures
  # because they will put Darwin in `meta.badPlatforms`.
  darwinUnsupportedFlags = [
    "alsaSupport"
    "cairoSupport"
    "dbusSupport"
    "fontconfigSupport"
    "gtkSupport"
    "netapiSupport"
    "pulseaudioSupport"
    "udevSupport"
    "v4lSupport"
    "vaSupport"
    "waylandSupport"
    "x11Support"
    "xineramaSupport"
  ];

  badPlatforms = lib.optional (
    !supportFlags.mingwSupport || lib.any (flag: supportFlags.${flag}) darwinUnsupportedFlags
    !mingwSupport
    || alsaSupport
    || cairoSupport
    || dbusSupport
    || fontconfigSupport
    || gtkSupport
    || netapiSupport
    || pulseaudioSupport
    || udevSupport
    || v4lSupport
    || vaSupport
    || waylandSupport
    || x11Support
    || xineramaSupport
  ) "x86_64-darwin";

  # Staging patches (from src.staging when useStaging is true)
@@ -101,7 +131,6 @@ stdenv.mkDerivation (
    strictDeps = true;

    nativeBuildInputs =
      with supportFlags;
      lib.optionals useStaging [
        autoconf
        hexdump
@@ -134,7 +163,6 @@ stdenv.mkDerivation (
        )
      )
      ++ toBuildInputs pkgArches (
        with supportFlags;
        pkgs:
        [
          pkgs.freetype
@@ -242,11 +270,11 @@ stdenv.mkDerivation (

    configureFlags =
      prevConfigFlags
      ++ lib.optionals supportFlags.waylandSupport [ "--with-wayland" ]
      ++ lib.optionals supportFlags.vulkanSupport [ "--with-vulkan" ]
      ++ lib.optionals (
        (stdenv.hostPlatform.isDarwin && !supportFlags.xineramaSupport) || !supportFlags.x11Support
      ) [ "--without-x" ];
      ++ lib.optionals waylandSupport [ "--with-wayland" ]
      ++ lib.optionals vulkanSupport [ "--with-vulkan" ]
      ++ lib.optionals ((stdenv.hostPlatform.isDarwin && !xineramaSupport) || !x11Support) [
        "--without-x"
      ];

    # Wine locates a lot of libraries dynamically through dlopen().  Add
    # them to the RPATH so that the user doesn't have to set them in
@@ -255,10 +283,10 @@ stdenv.mkDerivation (
      map (path: "-rpath " + path) (
        map (x: "${lib.getLib x}/lib") ([ stdenv.cc.cc ] ++ finalAttrs.buildInputs)
        # libpulsecommon.so is linked but not found otherwise
        ++ lib.optionals supportFlags.pulseaudioSupport (
        ++ lib.optionals pulseaudioSupport (
          map (x: "${lib.getLib x}/lib/pulseaudio") (toBuildInputs pkgArches (pkgs: [ pkgs.libpulseaudio ]))
        )
        ++ lib.optionals supportFlags.waylandSupport (
        ++ lib.optionals waylandSupport (
          map (x: "${lib.getLib x}/share/wayland-protocols") (
            toBuildInputs pkgArches (pkgs: [ pkgs.wayland-protocols ])
          )
@@ -281,13 +309,13 @@ stdenv.mkDerivation (
      let
        links = prefix: pkg: "ln -s ${pkg} $out/${prefix}/${pkg.name}";
      in
      lib.optionalString supportFlags.embedInstallers ''
      lib.optionalString embedInstallers ''
        mkdir -p $out/share/wine/gecko $out/share/wine/mono/
        ${lib.strings.concatStringsSep "\n" (
          (map (links "share/wine/gecko") geckos) ++ (map (links "share/wine/mono") monos)
        )}
      ''
      + lib.optionalString supportFlags.gstreamerSupport ''
      + lib.optionalString gstreamerSupport ''
        # Wrapping Wine is tricky.
        # https://github.com/NixOS/nixpkgs/issues/63170
        # https://github.com/NixOS/nixpkgs/issues/28486
@@ -320,8 +348,8 @@ stdenv.mkDerivation (
      "bindnow"
      "stackclashprotection"
    ]
    ++ lib.optional (stdenv.hostPlatform.isDarwin) "fortify"
    ++ lib.optional (supportFlags.mingwSupport) "format";
    ++ lib.optional stdenv.hostPlatform.isDarwin "fortify"
    ++ lib.optional mingwSupport "format";

    passthru = {
      inherit pkgArches;
+14 −42
Original line number Diff line number Diff line
@@ -6,7 +6,7 @@
# };
# Make additional configurations on demand:
# wine.override { wineBuild = "wine32"; wineRelease = "staging"; };
{
args@{
  lib,
  stdenv,
  callPackage,
@@ -50,6 +50,18 @@
let
  sources = callPackage ./sources.nix { };

  supportFlags = lib.filterAttrs (
    name: _:
    !builtins.elem name [
      "lib"
      "stdenv"
      "callPackage"
      "darwin"
      "wineRelease"
      "wineBuild"
    ]
  ) args;

  # Map user-facing release names to sources, pname suffix, and staging flag
  releaseInfo = {
    stable = {
@@ -77,47 +89,7 @@ let
  };

  baseWine = lib.getAttr wineBuild (
    callPackage ./packages.nix (
      releaseInfo.${wineRelease}
      // {
        supportFlags = {
          inherit
            alsaSupport
            cairoSupport
            cupsSupport
            cursesSupport
            dbusSupport
            embedInstallers
            fontconfigSupport
            gettextSupport
            gphoto2Support
            gstreamerSupport
            gtkSupport
            krb5Support
            mingwSupport
            netapiSupport
            odbcSupport
            openclSupport
            openglSupport
            pcapSupport
            pulseaudioSupport
            saneSupport
            sdlSupport
            tlsSupport
            udevSupport
            usbSupport
            v4lSupport
            vaSupport
            vulkanSupport
            waylandSupport
            x11Support
            ffmpegSupport
            xineramaSupport
            ;
        };
        inherit moltenvk;
      }
    )
    callPackage ./packages.nix (releaseInfo.${wineRelease} // supportFlags)
  );
in
if wineRelease == "yabridge" then
+102 −110
Original line number Diff line number Diff line
@@ -10,14 +10,14 @@
  src,
  pnameSuffix ? "",
  useStaging ? false,
  supportFlags,
  # Staging native build deps
  autoconf,
  hexdump,
  perl,
  python3,
  gitMinimal,
}:
  ...
}@args:

let
  inherit (src)
@@ -27,21 +27,28 @@ let
    gecko64
    mono
    ;

  # Args to pass through to base.nix (support flags, etc.)
  baseArgs = removeAttrs args [
    "stdenv_32bit"
    "lib"
    "pkgs"
    "pkgsi686Linux"
    "pkgsCross"
    "callPackage"
    "replaceVars"
  ];
in
{
  wine32 = pkgsi686Linux.callPackage ./base.nix {
  wine32 = pkgsi686Linux.callPackage ./base.nix (
    baseArgs
    // {
      pname = "wine";
    inherit
      src
      version
      supportFlags
      patches
      moltenvk
      pnameSuffix
      useStaging
      inherit version patches;
      # Forcing these `nativeBuildInputs` used in the `staging` to come
      # from ambient `pkgs`, rather than being provided by
      # `pkgsi686Linux.callPackage` for that platform.
      inherit
        autoconf
        hexdump
        perl
@@ -56,18 +63,13 @@ in
        "i686-linux"
        "x86_64-linux"
      ];
  };
  wine64 = callPackage ./base.nix {
    }
  );
  wine64 = callPackage ./base.nix (
    baseArgs
    // {
      pname = "wine64";
    inherit
      src
      version
      supportFlags
      patches
      moltenvk
      pnameSuffix
      useStaging
      ;
      inherit version patches;
      pkgArches = [ pkgs ];
      mingwGccs = with pkgsCross; [ mingwW64.buildPackages.gcc ];
      geckos = [ gecko64 ];
@@ -78,18 +80,13 @@ in
        "x86_64-darwin"
      ];
      mainProgram = "wine";
  };
  wineWow = callPackage ./base.nix {
    }
  );
  wineWow = callPackage ./base.nix (
    baseArgs
    // {
      pname = "wine-wow";
    inherit
      src
      version
      supportFlags
      patches
      moltenvk
      pnameSuffix
      useStaging
      ;
      inherit version patches;
      stdenv = stdenv_32bit;
      pkgArches = [
        pkgs
@@ -113,20 +110,14 @@ in
      };
      platforms = [ "x86_64-linux" ];
      mainProgram = "wine";
  };
  wineWow64 = callPackage ./base.nix {
    }
  );
  wineWow64 = callPackage ./base.nix (
    baseArgs
    // {
      pname = "wine-wow64";
    inherit
      src
      version
      patches
      moltenvk
      pnameSuffix
      useStaging
      ;
    supportFlags = supportFlags // {
      mingwSupport = true;
    }; # Required because we request "--enable-archs=x86_64"
      inherit version patches;
      mingwSupport = true; # Required because we request "--enable-archs=x86_64"
      pkgArches = [ pkgs ];
      mingwGccs = with pkgsCross; [
        mingw32.buildPackages.gcc
@@ -140,5 +131,6 @@ in
        "x86_64-darwin"
      ];
      mainProgram = "wine";
  };
    }
  );
}