diff --git a/pkgs/applications/emulators/wine/base.nix b/pkgs/applications/emulators/wine/base.nix index ff6a01114671..734cc4cf2815 100644 --- a/pkgs/applications/emulators/wine/base.nix +++ b/pkgs/applications/emulators/wine/base.nix @@ -18,7 +18,7 @@ pkg-config, nixosTests, supportFlags, - wineRelease, + pnameSuffix ? "", patches, moltenvk, buildScript ? null, @@ -95,9 +95,7 @@ stdenv.mkDerivation ( // { inherit version src; - pname = - prevName - + lib.optionalString (wineRelease != "stable" && wineRelease != "unstable") "-${wineRelease}"; + pname = prevName + pnameSuffix; # Fixes "Compiler cannot create executables" building wineWow with mingwSupport strictDeps = true; @@ -267,7 +265,8 @@ stdenv.mkDerivation ( ) ) ); - env.NIX_CFLAGS_COMPILE = lib.optionalString (wineRelease == "yabridge") "-std=gnu17"; + # Just here to avoid rebuilds for now. + env.NIX_CFLAGS_COMPILE = ""; # Don't shrink the ELF RPATHs in order to keep the extra RPATH # elements specified above. diff --git a/pkgs/applications/emulators/wine/default.nix b/pkgs/applications/emulators/wine/default.nix index 1d34ce36b5b1..5244bc9ea7e5 100644 --- a/pkgs/applications/emulators/wine/default.nix +++ b/pkgs/applications/emulators/wine/default.nix @@ -48,11 +48,38 @@ }: let - wine-build = - build: - lib.getAttr build ( - callPackage ./packages.nix { - inherit wineRelease; + sources = callPackage ./sources.nix { }; + + # Map user-facing release names to sources, pname suffix, and staging flag + releaseInfo = { + stable = { + src = sources.stable; + useStaging = false; + }; + unstable = { + src = sources.unstable; + useStaging = false; + }; + # Many versions have a "staging" variant, but when we say "staging", + # the version we want to use is "unstable". + staging = { + src = sources.unstable; + pnameSuffix = "-staging"; + useStaging = true; + }; + # "yabridge" enables staging too --- we are not interested in + # yabridge without the staging patches applied. + yabridge = { + src = sources.yabridge; + pnameSuffix = "-yabridge"; + useStaging = true; + }; + }; + + baseWine = lib.getAttr wineBuild ( + callPackage ./packages.nix ( + releaseInfo.${wineRelease} + // { supportFlags = { inherit alsaSupport @@ -90,6 +117,14 @@ let }; inherit moltenvk; } - ); + ) + ); in -wine-build wineBuild +if wineRelease == "yabridge" then + baseWine.overrideAttrs (old: { + env = old.env // { + NIX_CFLAGS_COMPILE = "-std=gnu17"; + }; + }) +else + baseWine diff --git a/pkgs/applications/emulators/wine/packages.nix b/pkgs/applications/emulators/wine/packages.nix index 6070c68b64c2..db91a073baec 100644 --- a/pkgs/applications/emulators/wine/packages.nix +++ b/pkgs/applications/emulators/wine/packages.nix @@ -7,7 +7,9 @@ callPackage, replaceVars, moltenvk, - wineRelease ? "stable", + src, + pnameSuffix ? "", + useStaging ? false, supportFlags, # Staging native build deps autoconf, @@ -18,19 +20,6 @@ }: let - sources = callPackage ./sources.nix { }; - - # "staging" of course enables staging, but for "yabridge" we do too - # --- we are not interested in yabridge without the staging patches - # applied. - useStaging = wineRelease == "staging" || wineRelease == "yabridge"; - - # Map wineRelease to actual source. Many versions have a "staging" - # variant, but when we say "staging", the version we want to use is - # "unstable". - baseRelease = if wineRelease == "staging" then "unstable" else wineRelease; - - src = lib.getAttr baseRelease (callPackage ./sources.nix { }); inherit (src) version patches @@ -48,7 +37,7 @@ in supportFlags patches moltenvk - wineRelease + pnameSuffix useStaging # Forcing these `nativeBuildInputs` used in the `staging` to come # from ambient `pkgs`, rather than being provided by @@ -76,7 +65,7 @@ in supportFlags patches moltenvk - wineRelease + pnameSuffix useStaging ; pkgArches = [ pkgs ]; @@ -98,7 +87,7 @@ in supportFlags patches moltenvk - wineRelease + pnameSuffix useStaging ; stdenv = stdenv_32bit; @@ -132,7 +121,7 @@ in version patches moltenvk - wineRelease + pnameSuffix useStaging ; supportFlags = supportFlags // {