···1212with import ./util.nix { inherit lib; };
13131414let
1515- patches' = patches;
1615 prevName = pname;
1717- prevPlatforms = platforms;
1816 prevConfigFlags = configureFlags;
1717+1918 setupHookDarwin = makeSetupHook {
2019 name = "darwin-mingw-hook";
2120 substitutions = {
···2322 mingwGccsSuffixSalts = map (gcc: gcc.suffixSalt) mingwGccs;
2423 };
2524 } ./setup-hook-darwin.sh;
2626- darwinUnsupportedFlags = [ "alsaSupport" "cairoSupport" "dbusSupport" "fontconfigSupport" "gtkSupport" "netapiSupport" "pulseaudioSupport" "udevSupport" "v4lSupport" "vaSupport" "waylandSupport" "x11Support" "xineramaSupport" ];
2727- darwinUnsupported = builtins.any (name: builtins.getAttr name supportFlags) darwinUnsupportedFlags;
2525+2626+ darwinFrameworks = lib.optionals stdenv.isDarwin (
2727+ toBuildInputs pkgArches (pkgs: with pkgs.buildPackages.darwin.apple_sdk.frameworks; [
2828+ CoreServices Foundation ForceFeedback AppKit OpenGL IOKit DiskArbitration PCSC Security
2929+ ApplicationServices AudioToolbox CoreAudio AudioUnit CoreMIDI OpenCL Cocoa Carbon
3030+ ])
3131+ );
3232+ # Building Wine with these flags isn’t supported on Darwin. Using any of them will result in an evaluation failures
3333+ # because they will put Darwin in `meta.badPlatforms`.
3434+ darwinUnsupportedFlags = [
3535+ "alsaSupport" "cairoSupport" "dbusSupport" "fontconfigSupport" "gtkSupport" "netapiSupport" "pulseaudioSupport"
3636+ "udevSupport" "v4lSupport" "vaSupport" "waylandSupport" "x11Support" "xineramaSupport"
3737+ ];
3838+3939+ badPlatforms = lib.optional (!supportFlags.mingwSupport || lib.any (flag: supportFlags.${flag}) darwinUnsupportedFlags) "x86_64-darwin";
2840in
2929-stdenv.mkDerivation ((lib.optionalAttrs (buildScript != null) {
3030- builder = buildScript;
3131-}) // (lib.optionalAttrs stdenv.isDarwin {
3232- postConfigure = ''
3333- # dynamic fallback, so this shouldn’t cause problems for older versions of macOS and will
3434- # provide additional functionality on newer ones. This can be removed once the x86_64-darwin
3535- # SDK is updated.
3636- sed 's|/\* #undef HAVE_MTLDEVICE_REGISTRYID \*/|#define HAVE_MTLDEVICE_REGISTRYID 1|' \
3737- -i include/config.h
3838- '';
3939- postBuild = ''
4040- # The Wine preloader must _not_ be linked to any system libraries, but `NIX_LDFLAGS` will link
4141- # to libintl, libiconv, and CoreFoundation no matter what. Delete the one that was built and
4242- # rebuild it with empty NIX_LDFLAGS.
4343- for preloader in wine-preloader wine64-preloader; do
4444- rm loader/$preloader &> /dev/null \
4545- && ( echo "Relinking loader/$preloader"; make loader/$preloader NIX_LDFLAGS="" NIX_LDFLAGS_${stdenv.cc.suffixSalt}="" ) \
4646- || echo "loader/$preloader not built, skipping relink."
4747- done
4848- '';
4949-}) // rec {
4141+stdenv.mkDerivation (finalAttrs:
4242+lib.optionalAttrs (buildScript != null) { builder = buildScript; }
4343+// lib.optionalAttrs stdenv.isDarwin {
4444+ postBuild = ''
4545+ # The Wine preloader must _not_ be linked to any system libraries, but `NIX_LDFLAGS` will link
4646+ # to libintl, libiconv, and CoreFoundation no matter what. Delete the one that was built and
4747+ # rebuild it with empty NIX_LDFLAGS.
4848+ for preloader in wine-preloader wine64-preloader; do
4949+ rm loader/$preloader &> /dev/null \
5050+ && ( echo "Relinking loader/$preloader"; make loader/$preloader NIX_LDFLAGS="" NIX_LDFLAGS_${stdenv.cc.suffixSalt}="" ) \
5151+ || echo "loader/$preloader not built, skipping relink."
5252+ done
5353+ '';
5454+}
5555+// {
5056 inherit version src;
51575258 pname = prevName + lib.optionalString (wineRelease != "stable" && wineRelease != "unstable") "-${wineRelease}";
···95101 ++ lib.optionals openclSupport [ pkgs.opencl-headers pkgs.ocl-icd ]
96102 ++ lib.optionals tlsSupport [ pkgs.openssl pkgs.gnutls ]
97103 ++ lib.optionals (openglSupport && !stdenv.isDarwin) [ pkgs.libGLU pkgs.libGL pkgs.mesa.osmesa pkgs.libdrm ]
9898- ++ lib.optionals stdenv.isDarwin (with pkgs.buildPackages.darwin.apple_sdk.frameworks; [
9999- CoreServices Foundation ForceFeedback AppKit OpenGL IOKit DiskArbitration PCSC Security
100100- ApplicationServices AudioToolbox CoreAudio AudioUnit CoreMIDI OpenCL Cocoa Carbon
101101- ])
104104+ ++ lib.optionals stdenv.isDarwin darwinFrameworks
102105 ++ lib.optionals (x11Support) (with pkgs.xorg; [
103106 libX11 libXcomposite libXcursor libXext libXfixes libXi libXrandr libXrender libXxf86vm
104107 ])
···107110 mesa # for libgbm
108111 ])));
109112110110- patches = [ ]
111111- ++ lib.optionals stdenv.isDarwin [
112112- # Wine uses `MTLDevice.registryID` in `winemac.drv`, but that property is not available in
113113- # the 10.12 SDK (current SDK on x86_64-darwin). That can be worked around by using selector
114114- # syntax. As of Wine 8.12, the logic has changed and uses selector syntax, but it still
115115- # uses property syntax in one place. The first patch is necessary only with older
116116- # versions of Wine. The second is needed on all versions of Wine.
117117- (lib.optional (lib.versionOlder version "8.12") ./darwin-metal-compat-pre8.12.patch)
118118- (lib.optional (lib.versionOlder version "8.18") ./darwin-metal-compat-pre8.18.patch)
119119- (lib.optional (lib.versionAtLeast version "8.18") ./darwin-metal-compat.patch)
120120- # Wine requires `qos.h`, which is not included by default on the 10.12 SDK in nixpkgs.
121121- ./darwin-qos.patch
122122- ]
123123- ++ patches';
124124-125125- # Because the 10.12 SDK doesn’t define `registryID`, clang assumes the undefined selector returns
126126- # `id`, which is a pointer. This causes implicit pointer to integer errors in clang 15+.
127127- # The following post-processing step adds a cast to `uint64_t` before the selector invocation to
128128- # silence these errors.
129129- postPatch = lib.optionalString stdenv.isDarwin ''
130130- sed -e 's|\(\[[A-Za-z_][][A-Za-z_0-9]* registryID\]\)|(uint64_t)\1|' \
131131- -i dlls/winemac.drv/cocoa_display.m
132132- '';
113113+ inherit patches;
133114134115 configureFlags = prevConfigFlags
135116 ++ lib.optionals supportFlags.waylandSupport [ "--with-wayland" ]
···140121 # them to the RPATH so that the user doesn't have to set them in
141122 # LD_LIBRARY_PATH.
142123 NIX_LDFLAGS = toString (map (path: "-rpath " + path) (
143143- map (x: "${lib.getLib x}/lib") ([ stdenv.cc.cc ] ++ buildInputs)
124124+ map (x: "${lib.getLib x}/lib") ([ stdenv.cc.cc ]
125125+ # Avoid adding rpath references to non-existent framework `lib` paths.
126126+ ++ lib.subtractLists darwinFrameworks finalAttrs.buildInputs)
144127 # libpulsecommon.so is linked but not found otherwise
145128 ++ lib.optionals supportFlags.pulseaudioSupport (map (x: "${lib.getLib x}/lib/pulseaudio")
146129 (toBuildInputs pkgArches (pkgs: [ pkgs.libpulseaudio ])))
···210193 fromSource
211194 binaryNativeCode # mono, gecko
212195 ];
213213- broken = stdenv.isDarwin && !supportFlags.mingwSupport;
214196 description = "An Open Source implementation of the Windows API on top of X, OpenGL, and Unix";
215215- platforms = if darwinUnsupported then (lib.remove "x86_64-darwin" prevPlatforms) else prevPlatforms;
197197+ inherit badPlatforms platforms;
216198 maintainers = with lib.maintainers; [ avnik raskin bendlas jmc-figueira reckenrode ];
217199 inherit mainProgram;
218200 };
···11-diff --git a/dlls/winemac.drv/cocoa_display.m b/dlls/winemac.drv/cocoa_display.m
22---- a/dlls/winemac.drv/cocoa_display.m
33-+++ b/dlls/winemac.drv/cocoa_display.m
44-@@ -289,7 +289,7 @@ static int macdrv_get_gpus_from_metal(struct macdrv_gpu** new_gpus, int* count)
55- * the primary GPU because we need to hide the integrated GPU for an automatic graphic switching pair to avoid apps
66- * using the integrated GPU. This is the behavior of Windows on a Mac. */
77- primary_device = [MTLCreateSystemDefaultDevice() autorelease];
88-- if (macdrv_get_gpu_info_from_registry_id(&primary_gpu, primary_device.registryID))
99-+ if (macdrv_get_gpu_info_from_registry_id(&primary_gpu, [primary_device registryID]))
1010- goto done;
1111-1212- /* Hide the integrated GPU if the system default device is a dedicated GPU */
1313-@@ -301,7 +301,7 @@ static int macdrv_get_gpus_from_metal(struct macdrv_gpu** new_gpus, int* count)
1414-1515- for (i = 0; i < devices.count; i++)
1616- {
1717-- if (macdrv_get_gpu_info_from_registry_id(&gpus[gpu_count], devices[i].registryID))
1818-+ if (macdrv_get_gpu_info_from_registry_id(&gpus[gpu_count], [devices[i] registryID]))
1919- goto done;
2020-2121- if (hide_integrated && devices[i].isLowPower)
2222-
···77, gtk3
88, gobject-introspection
99, libnotify
1010+, makeBinaryWrapper
1011, wrapGAppsHook3
1112, vte
1213, nixosTests
···2728 file
2829 intltool
2930 gobject-introspection
3131+ makeBinaryWrapper
3032 wrapGAppsHook3
3133 python3.pkgs.pytest-runner
3234 ];
···55575658 dontWrapGApps = true;
57596060+ # HACK: 'wrapPythonPrograms' will add things to the $PATH in the wrapper. This bleeds into the
6161+ # terminal session produced by terminator. To avoid this, we force wrapPythonPrograms to only
6262+ # use gappsWrapperArgs by redefining wrapProgram to ignore its arguments and only apply the
6363+ # wrapper arguments we want it to use.
6464+ # TODO: Adjust wrapPythonPrograms to respect an argument that tells it to leave $PATH alone.
5865 preFixup = ''
5959- makeWrapperArgs+=("''${gappsWrapperArgs[@]}")
6666+ wrapProgram() {
6767+ wrapProgramBinary "$1" "''${gappsWrapperArgs[@]}"
6868+ }
6069 '';
61706271 passthru.tests.test = nixosTests.terminal-emulators.terminator;