9 stdenvNoCC.mkDerivation (finalAttrs:
11 inherit (hostPlatform.uname) system;
12 # DXVK needs to be a separate derivation because it’s actually a set of DLLs for Windows that
13 # needs to be built with a cross-compiler.
14 dxvk32 = pkgsCross.mingw32.callPackage ./dxvk.nix {
15 inherit (finalAttrs) src version dxvkPatches;
17 dxvk64 = pkgsCross.mingwW64.callPackage ./dxvk.nix {
18 inherit (finalAttrs) src version dxvkPatches;
21 # Split out by platform to make maintenance easy in case supported versions on Darwin and other
22 # platforms diverge (due to the need for Darwin-specific patches that would fail to apply).
23 # Should that happen, set `darwin` to the last working `rev` and `hash`.
25 darwin = { inherit (default) rev hash version; };
27 rev = "v${finalAttrs.version}";
28 hash = "sha256-T93ZylxzJGprrP+j6axZwl2d3hJowMCUOKNjIyNzkmE=";
35 inherit (srcs."${system}" or srcs.default) version;
37 src = fetchFromGitHub {
40 inherit (srcs."${system}" or srcs.default) rev hash;
43 # Override this to patch DXVK itself (rather than the setup script).
44 dxvkPatches = lib.optionals stdenvNoCC.isDarwin [
45 # Patch DXVK to work with MoltenVK even though it doesn’t support some required features.
46 # Some games work poorly (particularly Unreal Engine 4 games), but others work pretty well.
47 ./darwin-dxvk-compat.patch
48 # Use synchronization primitives from the C++ standard library to avoid deadlocks on Darwin.
49 # See: https://www.reddit.com/r/macgaming/comments/t8liua/comment/hzsuce9/
50 ./darwin-thread-primitives.patch
53 outputs = [ "out" "bin" "lib" ];
55 # Also copy `mcfgthread-12.dll` due to DXVK’s being built in a MinGW cross environment.
56 patches = [ ./mcfgthread.patch ];
62 mkdir -p $out/bin $bin $lib
63 substitute setup_dxvk.sh $out/bin/setup_dxvk.sh \
64 --subst-var-by mcfgthreads32 "${pkgsCross.mingw32.windows.mcfgthreads}" \
65 --subst-var-by mcfgthreads64 "${pkgsCross.mingwW64.windows.mcfgthreads}" \
66 --replace 'basedir=$(dirname "$(readlink -f $0)")' "basedir=$bin"
67 chmod a+x $out/bin/setup_dxvk.sh
68 declare -A dxvks=( [x32]=${dxvk32} [x64]=${dxvk64} )
69 for arch in "''${!dxvks[@]}"; do
70 ln -s "''${dxvks[$arch]}/bin" $bin/$arch
71 ln -s "''${dxvks[$arch]}/lib" $lib/$arch
76 description = "A Vulkan-based translation layer for Direct3D 9/10/11";
77 homepage = "https://github.com/doitsujin/dxvk";
78 changelog = "https://github.com/doitsujin/dxvk/releases";
79 maintainers = [ lib.maintainers.reckenrode ];
80 license = lib.licenses.zlib;
81 platforms = [ "x86_64-darwin" "i686-linux" "x86_64-linux" ];