···12with import ./util.nix { inherit lib; };
1314let
15- patches' = patches;
16 prevName = pname;
17- prevPlatforms = platforms;
18 prevConfigFlags = configureFlags;
019 setupHookDarwin = makeSetupHook {
20 name = "darwin-mingw-hook";
21 substitutions = {
···23 mingwGccsSuffixSalts = map (gcc: gcc.suffixSalt) mingwGccs;
24 };
25 } ./setup-hook-darwin.sh;
26- darwinUnsupportedFlags = [ "alsaSupport" "cairoSupport" "dbusSupport" "fontconfigSupport" "gtkSupport" "netapiSupport" "pulseaudioSupport" "udevSupport" "v4lSupport" "vaSupport" "waylandSupport" "x11Support" "xineramaSupport" ];
27- darwinUnsupported = builtins.any (name: builtins.getAttr name supportFlags) darwinUnsupportedFlags;
000000000000028in
29-stdenv.mkDerivation ((lib.optionalAttrs (buildScript != null) {
30- builder = buildScript;
31-}) // (lib.optionalAttrs stdenv.isDarwin {
32- postConfigure = ''
33- # dynamic fallback, so this shouldn’t cause problems for older versions of macOS and will
34- # provide additional functionality on newer ones. This can be removed once the x86_64-darwin
35- # SDK is updated.
36- sed 's|/\* #undef HAVE_MTLDEVICE_REGISTRYID \*/|#define HAVE_MTLDEVICE_REGISTRYID 1|' \
37- -i include/config.h
38- '';
39- postBuild = ''
40- # The Wine preloader must _not_ be linked to any system libraries, but `NIX_LDFLAGS` will link
41- # to libintl, libiconv, and CoreFoundation no matter what. Delete the one that was built and
42- # rebuild it with empty NIX_LDFLAGS.
43- for preloader in wine-preloader wine64-preloader; do
44- rm loader/$preloader &> /dev/null \
45- && ( echo "Relinking loader/$preloader"; make loader/$preloader NIX_LDFLAGS="" NIX_LDFLAGS_${stdenv.cc.suffixSalt}="" ) \
46- || echo "loader/$preloader not built, skipping relink."
47- done
48- '';
49-}) // rec {
50 inherit version src;
5152 pname = prevName + lib.optionalString (wineRelease != "stable" && wineRelease != "unstable") "-${wineRelease}";
···95 ++ lib.optionals openclSupport [ pkgs.opencl-headers pkgs.ocl-icd ]
96 ++ lib.optionals tlsSupport [ pkgs.openssl pkgs.gnutls ]
97 ++ lib.optionals (openglSupport && !stdenv.isDarwin) [ pkgs.libGLU pkgs.libGL pkgs.mesa.osmesa pkgs.libdrm ]
98- ++ lib.optionals stdenv.isDarwin (with pkgs.buildPackages.darwin.apple_sdk.frameworks; [
99- CoreServices Foundation ForceFeedback AppKit OpenGL IOKit DiskArbitration PCSC Security
100- ApplicationServices AudioToolbox CoreAudio AudioUnit CoreMIDI OpenCL Cocoa Carbon
101- ])
102 ++ lib.optionals (x11Support) (with pkgs.xorg; [
103 libX11 libXcomposite libXcursor libXext libXfixes libXi libXrandr libXrender libXxf86vm
104 ])
···107 mesa # for libgbm
108 ])));
109110- patches = [ ]
111- ++ lib.optionals stdenv.isDarwin [
112- # Wine uses `MTLDevice.registryID` in `winemac.drv`, but that property is not available in
113- # the 10.12 SDK (current SDK on x86_64-darwin). That can be worked around by using selector
114- # syntax. As of Wine 8.12, the logic has changed and uses selector syntax, but it still
115- # uses property syntax in one place. The first patch is necessary only with older
116- # versions of Wine. The second is needed on all versions of Wine.
117- (lib.optional (lib.versionOlder version "8.12") ./darwin-metal-compat-pre8.12.patch)
118- (lib.optional (lib.versionOlder version "8.18") ./darwin-metal-compat-pre8.18.patch)
119- (lib.optional (lib.versionAtLeast version "8.18") ./darwin-metal-compat.patch)
120- # Wine requires `qos.h`, which is not included by default on the 10.12 SDK in nixpkgs.
121- ./darwin-qos.patch
122- ]
123- ++ patches';
124-125- # Because the 10.12 SDK doesn’t define `registryID`, clang assumes the undefined selector returns
126- # `id`, which is a pointer. This causes implicit pointer to integer errors in clang 15+.
127- # The following post-processing step adds a cast to `uint64_t` before the selector invocation to
128- # silence these errors.
129- postPatch = lib.optionalString stdenv.isDarwin ''
130- sed -e 's|\(\[[A-Za-z_][][A-Za-z_0-9]* registryID\]\)|(uint64_t)\1|' \
131- -i dlls/winemac.drv/cocoa_display.m
132- '';
133134 configureFlags = prevConfigFlags
135 ++ lib.optionals supportFlags.waylandSupport [ "--with-wayland" ]
···140 # them to the RPATH so that the user doesn't have to set them in
141 # LD_LIBRARY_PATH.
142 NIX_LDFLAGS = toString (map (path: "-rpath " + path) (
143- map (x: "${lib.getLib x}/lib") ([ stdenv.cc.cc ] ++ buildInputs)
00144 # libpulsecommon.so is linked but not found otherwise
145 ++ lib.optionals supportFlags.pulseaudioSupport (map (x: "${lib.getLib x}/lib/pulseaudio")
146 (toBuildInputs pkgArches (pkgs: [ pkgs.libpulseaudio ])))
···210 fromSource
211 binaryNativeCode # mono, gecko
212 ];
213- broken = stdenv.isDarwin && !supportFlags.mingwSupport;
214 description = "An Open Source implementation of the Windows API on top of X, OpenGL, and Unix";
215- platforms = if darwinUnsupported then (lib.remove "x86_64-darwin" prevPlatforms) else prevPlatforms;
216 maintainers = with lib.maintainers; [ avnik raskin bendlas jmc-figueira reckenrode ];
217 inherit mainProgram;
218 };
···12with import ./util.nix { inherit lib; };
1314let
015 prevName = pname;
016 prevConfigFlags = configureFlags;
17+18 setupHookDarwin = makeSetupHook {
19 name = "darwin-mingw-hook";
20 substitutions = {
···22 mingwGccsSuffixSalts = map (gcc: gcc.suffixSalt) mingwGccs;
23 };
24 } ./setup-hook-darwin.sh;
25+26+ darwinFrameworks = lib.optionals stdenv.isDarwin (
27+ toBuildInputs pkgArches (pkgs: with pkgs.buildPackages.darwin.apple_sdk.frameworks; [
28+ CoreServices Foundation ForceFeedback AppKit OpenGL IOKit DiskArbitration PCSC Security
29+ ApplicationServices AudioToolbox CoreAudio AudioUnit CoreMIDI OpenCL Cocoa Carbon
30+ ])
31+ );
32+ # Building Wine with these flags isn’t supported on Darwin. Using any of them will result in an evaluation failures
33+ # because they will put Darwin in `meta.badPlatforms`.
34+ darwinUnsupportedFlags = [
35+ "alsaSupport" "cairoSupport" "dbusSupport" "fontconfigSupport" "gtkSupport" "netapiSupport" "pulseaudioSupport"
36+ "udevSupport" "v4lSupport" "vaSupport" "waylandSupport" "x11Support" "xineramaSupport"
37+ ];
38+39+ badPlatforms = lib.optional (!supportFlags.mingwSupport || lib.any (flag: supportFlags.${flag}) darwinUnsupportedFlags) "x86_64-darwin";
40in
41+stdenv.mkDerivation (finalAttrs:
42+lib.optionalAttrs (buildScript != null) { builder = buildScript; }
43+// lib.optionalAttrs stdenv.isDarwin {
44+ postBuild = ''
45+ # The Wine preloader must _not_ be linked to any system libraries, but `NIX_LDFLAGS` will link
46+ # to libintl, libiconv, and CoreFoundation no matter what. Delete the one that was built and
47+ # rebuild it with empty NIX_LDFLAGS.
48+ for preloader in wine-preloader wine64-preloader; do
49+ rm loader/$preloader &> /dev/null \
50+ && ( echo "Relinking loader/$preloader"; make loader/$preloader NIX_LDFLAGS="" NIX_LDFLAGS_${stdenv.cc.suffixSalt}="" ) \
51+ || echo "loader/$preloader not built, skipping relink."
52+ done
53+ '';
54+}
55+// {
00000056 inherit version src;
5758 pname = prevName + lib.optionalString (wineRelease != "stable" && wineRelease != "unstable") "-${wineRelease}";
···101 ++ lib.optionals openclSupport [ pkgs.opencl-headers pkgs.ocl-icd ]
102 ++ lib.optionals tlsSupport [ pkgs.openssl pkgs.gnutls ]
103 ++ lib.optionals (openglSupport && !stdenv.isDarwin) [ pkgs.libGLU pkgs.libGL pkgs.mesa.osmesa pkgs.libdrm ]
104+ ++ lib.optionals stdenv.isDarwin darwinFrameworks
000105 ++ lib.optionals (x11Support) (with pkgs.xorg; [
106 libX11 libXcomposite libXcursor libXext libXfixes libXi libXrandr libXrender libXxf86vm
107 ])
···110 mesa # for libgbm
111 ])));
112113+ inherit patches;
0000000000000000000000114115 configureFlags = prevConfigFlags
116 ++ lib.optionals supportFlags.waylandSupport [ "--with-wayland" ]
···121 # them to the RPATH so that the user doesn't have to set them in
122 # LD_LIBRARY_PATH.
123 NIX_LDFLAGS = toString (map (path: "-rpath " + path) (
124+ map (x: "${lib.getLib x}/lib") ([ stdenv.cc.cc ]
125+ # Avoid adding rpath references to non-existent framework `lib` paths.
126+ ++ lib.subtractLists darwinFrameworks finalAttrs.buildInputs)
127 # libpulsecommon.so is linked but not found otherwise
128 ++ lib.optionals supportFlags.pulseaudioSupport (map (x: "${lib.getLib x}/lib/pulseaudio")
129 (toBuildInputs pkgArches (pkgs: [ pkgs.libpulseaudio ])))
···193 fromSource
194 binaryNativeCode # mono, gecko
195 ];
0196 description = "An Open Source implementation of the Windows API on top of X, OpenGL, and Unix";
197+ inherit badPlatforms platforms;
198 maintainers = with lib.maintainers; [ avnik raskin bendlas jmc-figueira reckenrode ];
199 inherit mainProgram;
200 };
···1-diff --git a/dlls/winemac.drv/cocoa_display.m b/dlls/winemac.drv/cocoa_display.m
2---- a/dlls/winemac.drv/cocoa_display.m
3-+++ b/dlls/winemac.drv/cocoa_display.m
4-@@ -289,7 +289,7 @@ static int macdrv_get_gpus_from_metal(struct macdrv_gpu** new_gpus, int* count)
5- * the primary GPU because we need to hide the integrated GPU for an automatic graphic switching pair to avoid apps
6- * using the integrated GPU. This is the behavior of Windows on a Mac. */
7- primary_device = [MTLCreateSystemDefaultDevice() autorelease];
8-- if (macdrv_get_gpu_info_from_registry_id(&primary_gpu, primary_device.registryID))
9-+ if (macdrv_get_gpu_info_from_registry_id(&primary_gpu, [primary_device registryID]))
10- goto done;
11-12- /* Hide the integrated GPU if the system default device is a dedicated GPU */
13-@@ -301,7 +301,7 @@ static int macdrv_get_gpus_from_metal(struct macdrv_gpu** new_gpus, int* count)
14-15- for (i = 0; i < devices.count; i++)
16- {
17-- if (macdrv_get_gpu_info_from_registry_id(&gpus[gpu_count], devices[i].registryID))
18-+ if (macdrv_get_gpu_info_from_registry_id(&gpus[gpu_count], [devices[i] registryID]))
19- goto done;
20-21- if (hide_integrated && devices[i].isLowPower)
22-
···7, gtk3
8, gobject-introspection
9, libnotify
10+, makeBinaryWrapper
11, wrapGAppsHook3
12, vte
13, nixosTests
···28 file
29 intltool
30 gobject-introspection
31+ makeBinaryWrapper
32 wrapGAppsHook3
33 python3.pkgs.pytest-runner
34 ];
···5758 dontWrapGApps = true;
5960+ # HACK: 'wrapPythonPrograms' will add things to the $PATH in the wrapper. This bleeds into the
61+ # terminal session produced by terminator. To avoid this, we force wrapPythonPrograms to only
62+ # use gappsWrapperArgs by redefining wrapProgram to ignore its arguments and only apply the
63+ # wrapper arguments we want it to use.
64+ # TODO: Adjust wrapPythonPrograms to respect an argument that tells it to leave $PATH alone.
65 preFixup = ''
66+ wrapProgram() {
67+ wrapProgramBinary "$1" "''${gappsWrapperArgs[@]}"
68+ }
69 '';
7071 passthru.tests.test = nixosTests.terminal-emulators.terminator;
···11 sha256 = "sha256-wA2RDVOU5pZ1YI617g9QTVz9pB6ZCi2akbqsbfk+P5I=";
12 };
13000014 # perl is used at build time to gather the ferm version.
15 nativeBuildInputs = [ makeWrapper perl ];
16 buildInputs = [ perl ];
···11 sha256 = "sha256-wA2RDVOU5pZ1YI617g9QTVz9pB6ZCi2akbqsbfk+P5I=";
12 };
1314+ patches = [
15+ ./import-ferm-wrapped.patch
16+ ];
17+18 # perl is used at build time to gather the ferm version.
19 nativeBuildInputs = [ makeWrapper perl ];
20 buildInputs = [ perl ];