2023-07-15 17:15:38 +00:00
|
|
|
|
{ stdenv, lib, pkgArches, makeSetupHook,
|
2022-03-30 09:31:56 +00:00
|
|
|
|
pname, version, src, mingwGccs, monos, geckos, platforms,
|
2021-01-05 17:05:55 +00:00
|
|
|
|
bison, flex, fontforge, makeWrapper, pkg-config,
|
2023-03-15 16:39:30 +00:00
|
|
|
|
nixosTests,
|
2020-04-24 23:36:52 +00:00
|
|
|
|
supportFlags,
|
2024-01-25 14:12:00 +00:00
|
|
|
|
wineRelease,
|
2020-11-30 08:33:03 +00:00
|
|
|
|
patches,
|
2022-02-21 08:47:16 +00:00
|
|
|
|
moltenvk,
|
2022-08-12 12:06:08 +00:00
|
|
|
|
buildScript ? null, configureFlags ? [], mainProgram ? "wine"
|
2020-04-24 23:36:52 +00:00
|
|
|
|
}:
|
|
|
|
|
|
|
|
|
|
with import ./util.nix { inherit lib; };
|
|
|
|
|
|
|
|
|
|
let
|
2020-11-30 08:33:03 +00:00
|
|
|
|
patches' = patches;
|
2022-03-30 09:31:56 +00:00
|
|
|
|
prevName = pname;
|
2022-01-25 03:21:06 +00:00
|
|
|
|
prevPlatforms = platforms;
|
|
|
|
|
prevConfigFlags = configureFlags;
|
2022-02-21 08:47:16 +00:00
|
|
|
|
setupHookDarwin = makeSetupHook {
|
|
|
|
|
name = "darwin-mingw-hook";
|
|
|
|
|
substitutions = {
|
|
|
|
|
darwinSuffixSalt = stdenv.cc.suffixSalt;
|
|
|
|
|
mingwGccsSuffixSalts = map (gcc: gcc.suffixSalt) mingwGccs;
|
|
|
|
|
};
|
|
|
|
|
} ./setup-hook-darwin.sh;
|
2024-02-29 20:09:43 +00:00
|
|
|
|
darwinUnsupportedFlags = [ "alsaSupport" "cairoSupport" "dbusSupport" "fontconfigSupport" "gtkSupport" "netapiSupport" "pulseaudioSupport" "udevSupport" "v4lSupport" "vaSupport" "waylandSupport" "x11Support" "xineramaSupport" ];
|
|
|
|
|
darwinUnsupported = builtins.any (name: builtins.getAttr name supportFlags) darwinUnsupportedFlags;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
in
|
|
|
|
|
stdenv.mkDerivation ((lib.optionalAttrs (buildScript != null) {
|
|
|
|
|
builder = buildScript;
|
2022-02-21 08:47:16 +00:00
|
|
|
|
}) // (lib.optionalAttrs stdenv.isDarwin {
|
|
|
|
|
postConfigure = ''
|
|
|
|
|
# dynamic fallback, so this shouldn’t cause problems for older versions of macOS and will
|
|
|
|
|
# provide additional functionality on newer ones. This can be removed once the x86_64-darwin
|
|
|
|
|
# SDK is updated.
|
|
|
|
|
sed 's|/\* #undef HAVE_MTLDEVICE_REGISTRYID \*/|#define HAVE_MTLDEVICE_REGISTRYID 1|' \
|
|
|
|
|
-i include/config.h
|
|
|
|
|
'';
|
|
|
|
|
postBuild = ''
|
|
|
|
|
# The Wine preloader must _not_ be linked to any system libraries, but `NIX_LDFLAGS` will link
|
|
|
|
|
# to libintl, libiconv, and CoreFoundation no matter what. Delete the one that was built and
|
|
|
|
|
# rebuild it with empty NIX_LDFLAGS.
|
2024-01-02 11:29:13 +00:00
|
|
|
|
for preloader in wine-preloader wine64-preloader; do
|
|
|
|
|
rm loader/$preloader &> /dev/null \
|
|
|
|
|
&& ( echo "Relinking loader/$preloader"; make loader/$preloader NIX_LDFLAGS="" NIX_LDFLAGS_${stdenv.cc.suffixSalt}="" ) \
|
|
|
|
|
|| echo "loader/$preloader not built, skipping relink."
|
|
|
|
|
done
|
2022-02-21 08:47:16 +00:00
|
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
|
}) // rec {
|
2022-03-30 09:31:56 +00:00
|
|
|
|
inherit version src;
|
2022-01-25 03:21:06 +00:00
|
|
|
|
|
2024-02-29 20:09:43 +00:00
|
|
|
|
pname = prevName + lib.optionalString (wineRelease != "stable" && wineRelease != "unstable") "-${wineRelease}";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
2020-11-15 13:44:38 +00:00
|
|
|
|
# Fixes "Compiler cannot create executables" building wineWow with mingwSupport
|
2021-01-05 17:05:55 +00:00
|
|
|
|
strictDeps = true;
|
2020-11-15 13:44:38 +00:00
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
|
nativeBuildInputs = [
|
2021-01-05 17:05:55 +00:00
|
|
|
|
bison
|
|
|
|
|
flex
|
|
|
|
|
fontforge
|
|
|
|
|
makeWrapper
|
|
|
|
|
pkg-config
|
2020-11-15 13:44:38 +00:00
|
|
|
|
]
|
2022-02-21 08:47:16 +00:00
|
|
|
|
++ lib.optionals supportFlags.mingwSupport (mingwGccs
|
|
|
|
|
++ lib.optional stdenv.isDarwin setupHookDarwin);
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
|
|
buildInputs = toBuildInputs pkgArches (with supportFlags; (pkgs:
|
2022-02-21 08:47:16 +00:00
|
|
|
|
[ pkgs.freetype pkgs.perl pkgs.libunwind ]
|
2020-04-24 23:36:52 +00:00
|
|
|
|
++ lib.optional stdenv.isLinux pkgs.libcap
|
2022-02-21 08:47:16 +00:00
|
|
|
|
++ lib.optional stdenv.isDarwin pkgs.libinotify-kqueue
|
2020-04-24 23:36:52 +00:00
|
|
|
|
++ lib.optional cupsSupport pkgs.cups
|
|
|
|
|
++ lib.optional gettextSupport pkgs.gettext
|
|
|
|
|
++ lib.optional dbusSupport pkgs.dbus
|
|
|
|
|
++ lib.optional cairoSupport pkgs.cairo
|
|
|
|
|
++ lib.optional odbcSupport pkgs.unixODBC
|
|
|
|
|
++ lib.optional netapiSupport pkgs.samba4
|
|
|
|
|
++ lib.optional cursesSupport pkgs.ncurses
|
|
|
|
|
++ lib.optional vaSupport pkgs.libva
|
|
|
|
|
++ lib.optional pcapSupport pkgs.libpcap
|
|
|
|
|
++ lib.optional v4lSupport pkgs.libv4l
|
|
|
|
|
++ lib.optional saneSupport pkgs.sane-backends
|
|
|
|
|
++ lib.optional gphoto2Support pkgs.libgphoto2
|
2022-02-21 08:47:16 +00:00
|
|
|
|
++ lib.optional krb5Support pkgs.libkrb5
|
2020-04-24 23:36:52 +00:00
|
|
|
|
++ lib.optional fontconfigSupport pkgs.fontconfig
|
2021-06-28 23:13:55 +00:00
|
|
|
|
++ lib.optional alsaSupport pkgs.alsa-lib
|
2020-04-24 23:36:52 +00:00
|
|
|
|
++ lib.optional pulseaudioSupport pkgs.libpulseaudio
|
2023-10-09 19:29:22 +00:00
|
|
|
|
++ lib.optional (xineramaSupport && x11Support) pkgs.xorg.libXinerama
|
2020-04-24 23:36:52 +00:00
|
|
|
|
++ lib.optional udevSupport pkgs.udev
|
2022-02-21 08:47:16 +00:00
|
|
|
|
++ lib.optional vulkanSupport (if stdenv.isDarwin then moltenvk else pkgs.vulkan-loader)
|
2020-04-24 23:36:52 +00:00
|
|
|
|
++ lib.optional sdlSupport pkgs.SDL2
|
2022-02-21 08:47:16 +00:00
|
|
|
|
++ lib.optional usbSupport pkgs.libusb1
|
2020-04-24 23:36:52 +00:00
|
|
|
|
++ lib.optionals gstreamerSupport (with pkgs.gst_all_1;
|
2023-07-15 17:15:38 +00:00
|
|
|
|
[ gstreamer gst-plugins-base gst-plugins-good gst-plugins-ugly gst-libav gst-plugins-bad ])
|
2020-04-24 23:36:52 +00:00
|
|
|
|
++ lib.optionals gtkSupport [ pkgs.gtk3 pkgs.glib ]
|
|
|
|
|
++ lib.optionals openclSupport [ pkgs.opencl-headers pkgs.ocl-icd ]
|
|
|
|
|
++ lib.optionals tlsSupport [ pkgs.openssl pkgs.gnutls ]
|
2021-10-07 14:46:35 +00:00
|
|
|
|
++ lib.optionals (openglSupport && !stdenv.isDarwin) [ pkgs.libGLU pkgs.libGL pkgs.mesa.osmesa pkgs.libdrm ]
|
2020-04-24 23:36:52 +00:00
|
|
|
|
++ lib.optionals stdenv.isDarwin (with pkgs.buildPackages.darwin.apple_sdk.frameworks; [
|
2023-10-09 19:29:22 +00:00
|
|
|
|
CoreServices Foundation ForceFeedback AppKit OpenGL IOKit DiskArbitration PCSC Security
|
2023-02-09 11:40:11 +00:00
|
|
|
|
ApplicationServices AudioToolbox CoreAudio AudioUnit CoreMIDI OpenCL Cocoa Carbon
|
2020-04-24 23:36:52 +00:00
|
|
|
|
])
|
2023-10-09 19:29:22 +00:00
|
|
|
|
++ lib.optionals (x11Support) (with pkgs.xorg; [
|
|
|
|
|
libX11 libXcomposite libXcursor libXext libXfixes libXi libXrandr libXrender libXxf86vm
|
2022-01-25 03:21:06 +00:00
|
|
|
|
])
|
|
|
|
|
++ lib.optionals waylandSupport (with pkgs; [
|
|
|
|
|
wayland libxkbcommon wayland-protocols wayland.dev libxkbcommon.dev
|
2022-11-04 12:27:35 +00:00
|
|
|
|
mesa # for libgbm
|
2021-01-05 17:05:55 +00:00
|
|
|
|
])));
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
2022-02-21 08:47:16 +00:00
|
|
|
|
patches = [ ]
|
2023-03-08 16:32:21 +00:00
|
|
|
|
++ lib.optionals stdenv.isDarwin [
|
2023-10-09 19:29:22 +00:00
|
|
|
|
# Wine uses `MTLDevice.registryID` in `winemac.drv`, but that property is not available in
|
|
|
|
|
# the 10.12 SDK (current SDK on x86_64-darwin). That can be worked around by using selector
|
|
|
|
|
# syntax. As of Wine 8.12, the logic has changed and uses selector syntax, but it still
|
|
|
|
|
# uses property syntax in one place. The first patch is necessary only with older
|
|
|
|
|
# versions of Wine. The second is needed on all versions of Wine.
|
|
|
|
|
(lib.optional (lib.versionOlder version "8.12") ./darwin-metal-compat-pre8.12.patch)
|
2024-01-02 11:29:13 +00:00
|
|
|
|
(lib.optional (lib.versionOlder version "8.18") ./darwin-metal-compat-pre8.18.patch)
|
|
|
|
|
(lib.optional (lib.versionAtLeast version "8.18") ./darwin-metal-compat.patch)
|
2023-03-08 16:32:21 +00:00
|
|
|
|
# Wine requires `qos.h`, which is not included by default on the 10.12 SDK in nixpkgs.
|
|
|
|
|
./darwin-qos.patch
|
|
|
|
|
]
|
2022-02-21 08:47:16 +00:00
|
|
|
|
++ patches';
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
2023-10-09 19:29:22 +00:00
|
|
|
|
# Because the 10.12 SDK doesn’t define `registryID`, clang assumes the undefined selector returns
|
|
|
|
|
# `id`, which is a pointer. This causes implicit pointer to integer errors in clang 15+.
|
|
|
|
|
# The following post-processing step adds a cast to `uint64_t` before the selector invocation to
|
|
|
|
|
# silence these errors.
|
|
|
|
|
postPatch = lib.optionalString stdenv.isDarwin ''
|
|
|
|
|
sed -e 's|\(\[[A-Za-z_][][A-Za-z_0-9]* registryID\]\)|(uint64_t)\1|' \
|
|
|
|
|
-i dlls/winemac.drv/cocoa_display.m
|
|
|
|
|
'';
|
|
|
|
|
|
2022-01-25 03:21:06 +00:00
|
|
|
|
configureFlags = prevConfigFlags
|
|
|
|
|
++ lib.optionals supportFlags.waylandSupport [ "--with-wayland" ]
|
|
|
|
|
++ lib.optionals supportFlags.vulkanSupport [ "--with-vulkan" ]
|
2024-02-29 20:09:43 +00:00
|
|
|
|
++ lib.optionals ((stdenv.isDarwin && !supportFlags.xineramaSupport) || !supportFlags.x11Support) [ "--without-x" ];
|
2022-01-25 03:21:06 +00:00
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
|
# 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
|
|
|
|
|
# LD_LIBRARY_PATH.
|
|
|
|
|
NIX_LDFLAGS = toString (map (path: "-rpath " + path) (
|
|
|
|
|
map (x: "${lib.getLib x}/lib") ([ stdenv.cc.cc ] ++ buildInputs)
|
|
|
|
|
# libpulsecommon.so is linked but not found otherwise
|
|
|
|
|
++ lib.optionals supportFlags.pulseaudioSupport (map (x: "${lib.getLib x}/lib/pulseaudio")
|
|
|
|
|
(toBuildInputs pkgArches (pkgs: [ pkgs.libpulseaudio ])))
|
2022-01-25 03:21:06 +00:00
|
|
|
|
++ lib.optionals supportFlags.waylandSupport (map (x: "${lib.getLib x}/share/wayland-protocols")
|
|
|
|
|
(toBuildInputs pkgArches (pkgs: [ pkgs.wayland-protocols ])))
|
2020-04-24 23:36:52 +00:00
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
# Don't shrink the ELF RPATHs in order to keep the extra RPATH
|
|
|
|
|
# elements specified above.
|
|
|
|
|
dontPatchELF = true;
|
|
|
|
|
|
|
|
|
|
## FIXME
|
|
|
|
|
# Add capability to ignore known failing tests
|
|
|
|
|
# and enable doCheck
|
|
|
|
|
doCheck = false;
|
|
|
|
|
|
|
|
|
|
postInstall = let
|
|
|
|
|
links = prefix: pkg: "ln -s ${pkg} $out/${prefix}/${pkg.name}";
|
2021-09-28 08:13:01 +00:00
|
|
|
|
in lib.optionalString supportFlags.embedInstallers ''
|
2020-04-24 23:36:52 +00:00
|
|
|
|
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 ''
|
|
|
|
|
# Wrapping Wine is tricky.
|
|
|
|
|
# https://github.com/NixOS/nixpkgs/issues/63170
|
|
|
|
|
# https://github.com/NixOS/nixpkgs/issues/28486
|
|
|
|
|
# The main problem is that wine-preloader opens and loads the wine(64) binary, and
|
|
|
|
|
# breakage occurs if it finds a shell script instead of the real binary. We solve this
|
|
|
|
|
# by setting WINELOADER to point to the original binary. Additionally, the locations
|
|
|
|
|
# of the 32-bit and 64-bit binaries must differ only by the presence of "64" at the
|
|
|
|
|
# end, due to the logic Wine uses to find the other binary (see get_alternate_loader
|
|
|
|
|
# in dlls/kernel32/process.c). Therefore we do not use wrapProgram which would move
|
|
|
|
|
# the binaries to ".wine-wrapped" and ".wine64-wrapped", but use makeWrapper directly,
|
|
|
|
|
# and move the binaries to ".wine" and ".wine64".
|
|
|
|
|
for i in wine wine64 ; do
|
|
|
|
|
prog="$out/bin/$i"
|
|
|
|
|
if [ -e "$prog" ]; then
|
|
|
|
|
hidden="$(dirname "$prog")/.$(basename "$prog")"
|
|
|
|
|
mv "$prog" "$hidden"
|
|
|
|
|
makeWrapper "$hidden" "$prog" \
|
|
|
|
|
--argv0 "" \
|
|
|
|
|
--set WINELOADER "$hidden" \
|
|
|
|
|
--prefix GST_PLUGIN_SYSTEM_PATH_1_0 ":" "$GST_PLUGIN_SYSTEM_PATH_1_0"
|
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
'';
|
|
|
|
|
|
2022-06-16 17:23:12 +00:00
|
|
|
|
enableParallelBuilding = true;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
|
|
# https://bugs.winehq.org/show_bug.cgi?id=43530
|
|
|
|
|
# https://github.com/NixOS/nixpkgs/issues/31989
|
|
|
|
|
hardeningDisable = [ "bindnow" ]
|
2020-11-15 13:44:38 +00:00
|
|
|
|
++ lib.optional (stdenv.hostPlatform.isDarwin) "fortify"
|
|
|
|
|
++ lib.optional (supportFlags.mingwSupport) "format";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
2022-01-25 03:21:06 +00:00
|
|
|
|
passthru = {
|
|
|
|
|
inherit pkgArches;
|
2022-12-17 10:02:37 +00:00
|
|
|
|
inherit (src) updateScript;
|
2022-01-25 03:21:06 +00:00
|
|
|
|
tests = { inherit (nixosTests) wine; };
|
|
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
|
meta = {
|
2022-01-25 03:21:06 +00:00
|
|
|
|
inherit version;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
homepage = "https://www.winehq.org/";
|
2021-01-17 00:15:33 +00:00
|
|
|
|
license = with lib.licenses; [ lgpl21Plus ];
|
2022-06-26 10:26:21 +00:00
|
|
|
|
sourceProvenance = with lib.sourceTypes; [
|
|
|
|
|
fromSource
|
|
|
|
|
binaryNativeCode # mono, gecko
|
|
|
|
|
];
|
2024-01-02 11:29:13 +00:00
|
|
|
|
broken = stdenv.isDarwin && !supportFlags.mingwSupport;
|
2024-02-29 20:09:43 +00:00
|
|
|
|
description = "An Open Source implementation of the Windows API on top of X, OpenGL, and Unix";
|
|
|
|
|
platforms = if darwinUnsupported then (lib.remove "x86_64-darwin" prevPlatforms) else prevPlatforms;
|
2023-10-09 19:29:22 +00:00
|
|
|
|
maintainers = with lib.maintainers; [ avnik raskin bendlas jmc-figueira reckenrode ];
|
2022-08-12 12:06:08 +00:00
|
|
|
|
inherit mainProgram;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
};
|
|
|
|
|
})
|