From 5c02baae7acfa5bc124bc92b545ba428a61c4b5a Mon Sep 17 00:00:00 2001 From: John Ericson Date: Sat, 7 Feb 2026 00:16:12 -0500 Subject: [PATCH] wine: Inline `supportFlags` in `base.nix` I would like to get rid of `default.nix` entirely, but doing so involves some back-compat issues. This seems like it might be the last change I can make before those back-compat issues become unavoidable? --- pkgs/applications/emulators/wine/base.nix | 92 +++++--- pkgs/applications/emulators/wine/default.nix | 56 ++--- pkgs/applications/emulators/wine/packages.nix | 212 +++++++++--------- 3 files changed, 176 insertions(+), 184 deletions(-) diff --git a/pkgs/applications/emulators/wine/base.nix b/pkgs/applications/emulators/wine/base.nix index 734cc4cf2815..db34318d5545 100644 --- a/pkgs/applications/emulators/wine/base.nix +++ b/pkgs/applications/emulators/wine/base.nix @@ -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 isn’t 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; diff --git a/pkgs/applications/emulators/wine/default.nix b/pkgs/applications/emulators/wine/default.nix index 5244bc9ea7e5..ca3f2e9bbc44 100644 --- a/pkgs/applications/emulators/wine/default.nix +++ b/pkgs/applications/emulators/wine/default.nix @@ -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 diff --git a/pkgs/applications/emulators/wine/packages.nix b/pkgs/applications/emulators/wine/packages.nix index af9082a7d8f9..4ca991320cd5 100644 --- a/pkgs/applications/emulators/wine/packages.nix +++ b/pkgs/applications/emulators/wine/packages.nix @@ -10,14 +10,14 @@ src, pnameSuffix ? "", useStaging ? false, - supportFlags, # Staging native build deps autoconf, hexdump, perl, python3, gitMinimal, -}: + ... +}@args: let inherit (src) @@ -27,118 +27,110 @@ 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 { - pname = "wine"; - inherit - src - version - supportFlags - patches - moltenvk - pnameSuffix - useStaging + wine32 = pkgsi686Linux.callPackage ./base.nix ( + baseArgs + // { + pname = "wine"; + 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. - autoconf - hexdump - perl - python3 - gitMinimal - ; - pkgArches = [ pkgsi686Linux ]; - geckos = [ gecko32 ]; - mingwGccs = with pkgsCross; [ mingw32.buildPackages.gcc ]; - monos = [ mono ]; - platforms = [ - "i686-linux" - "x86_64-linux" - ]; - }; - wine64 = callPackage ./base.nix { - pname = "wine64"; - inherit - src - version - supportFlags - patches - moltenvk - pnameSuffix - useStaging - ; - pkgArches = [ pkgs ]; - mingwGccs = with pkgsCross; [ mingwW64.buildPackages.gcc ]; - geckos = [ gecko64 ]; - monos = [ mono ]; - configureFlags = [ "--enable-win64" ]; - platforms = [ - "x86_64-linux" - "x86_64-darwin" - ]; - mainProgram = "wine"; - }; - wineWow = callPackage ./base.nix { - pname = "wine-wow"; - inherit - src - version - supportFlags - patches - moltenvk - pnameSuffix - useStaging - ; - stdenv = stdenv_32bit; - pkgArches = [ - pkgs - pkgsi686Linux - ]; - geckos = [ - gecko32 - gecko64 - ]; - mingwGccs = with pkgsCross; [ - mingw32.buildPackages.gcc - mingwW64.buildPackages.gcc - ]; - monos = [ mono ]; - buildScript = replaceVars ./builder-wow.sh { - # pkgconfig has trouble picking the right architecture - pkgconfig64remove = lib.makeSearchPathOutput "dev" "lib/pkgconfig" [ - pkgs.glib - pkgs.gst_all_1.gstreamer + inherit + autoconf + hexdump + perl + python3 + gitMinimal + ; + pkgArches = [ pkgsi686Linux ]; + geckos = [ gecko32 ]; + mingwGccs = with pkgsCross; [ mingw32.buildPackages.gcc ]; + monos = [ mono ]; + platforms = [ + "i686-linux" + "x86_64-linux" ]; - }; - platforms = [ "x86_64-linux" ]; - mainProgram = "wine"; - }; - wineWow64 = callPackage ./base.nix { - pname = "wine-wow64"; - inherit - src - version - patches - moltenvk - pnameSuffix - useStaging - ; - supportFlags = supportFlags // { - mingwSupport = true; - }; # Required because we request "--enable-archs=x86_64" - pkgArches = [ pkgs ]; - mingwGccs = with pkgsCross; [ - mingw32.buildPackages.gcc - mingwW64.buildPackages.gcc - ]; - geckos = [ gecko64 ]; - monos = [ mono ]; - configureFlags = [ "--enable-archs=x86_64,i386" ]; - platforms = [ - "x86_64-linux" - "x86_64-darwin" - ]; - mainProgram = "wine"; - }; + } + ); + wine64 = callPackage ./base.nix ( + baseArgs + // { + pname = "wine64"; + inherit version patches; + pkgArches = [ pkgs ]; + mingwGccs = with pkgsCross; [ mingwW64.buildPackages.gcc ]; + geckos = [ gecko64 ]; + monos = [ mono ]; + configureFlags = [ "--enable-win64" ]; + platforms = [ + "x86_64-linux" + "x86_64-darwin" + ]; + mainProgram = "wine"; + } + ); + wineWow = callPackage ./base.nix ( + baseArgs + // { + pname = "wine-wow"; + inherit version patches; + stdenv = stdenv_32bit; + pkgArches = [ + pkgs + pkgsi686Linux + ]; + geckos = [ + gecko32 + gecko64 + ]; + mingwGccs = with pkgsCross; [ + mingw32.buildPackages.gcc + mingwW64.buildPackages.gcc + ]; + monos = [ mono ]; + buildScript = replaceVars ./builder-wow.sh { + # pkgconfig has trouble picking the right architecture + pkgconfig64remove = lib.makeSearchPathOutput "dev" "lib/pkgconfig" [ + pkgs.glib + pkgs.gst_all_1.gstreamer + ]; + }; + platforms = [ "x86_64-linux" ]; + mainProgram = "wine"; + } + ); + wineWow64 = callPackage ./base.nix ( + baseArgs + // { + pname = "wine-wow64"; + inherit version patches; + mingwSupport = true; # Required because we request "--enable-archs=x86_64" + pkgArches = [ pkgs ]; + mingwGccs = with pkgsCross; [ + mingw32.buildPackages.gcc + mingwW64.buildPackages.gcc + ]; + geckos = [ gecko64 ]; + monos = [ mono ]; + configureFlags = [ "--enable-archs=x86_64,i386" ]; + platforms = [ + "x86_64-linux" + "x86_64-darwin" + ]; + mainProgram = "wine"; + } + ); }