diff --git a/pkgs/misc/dxvk/default.nix b/pkgs/misc/dxvk/default.nix index 817014e192b1..cf1f12a2b71f 100644 --- a/pkgs/misc/dxvk/default.nix +++ b/pkgs/misc/dxvk/default.nix @@ -1,62 +1,23 @@ { lib -, pkgs , stdenvNoCC , fetchFromGitHub , pkgsCross +, stdenv , bash }: stdenvNoCC.mkDerivation (finalAttrs: let - system = lib.toLower stdenvNoCC.targetPlatform.uname.system; - - # DXVK needs to be a separate derivation because it’s actually a set of DLLs for Windows that - # needs to be built with a cross-compiler. - dxvk32 = pkgsCross.mingw32.callPackage ./dxvk.nix { - inherit (finalAttrs) src version dxvkPatches; - }; - dxvk64 = pkgsCross.mingwW64.callPackage ./dxvk.nix { - inherit (finalAttrs) src version dxvkPatches; - }; - - # Split out by platform to make maintenance easy in case supported versions on Darwin and other - # platforms diverge (due to the need for Darwin-specific patches that would fail to apply). - # Should that happen, set `darwin` to the last working `rev` and `hash`. - srcs = rec { - darwin = { - rev = "v${finalAttrs.version}"; - hash = "sha256-T93ZylxzJGprrP+j6axZwl2d3hJowMCUOKNjIyNzkmE="; - version = "1.10.3"; - }; - default = { - rev = "v${finalAttrs.version}"; - hash = "sha256-mboVLdPgZMzmqyeF0jAloEz6xqfIDiY/X98e7l2KZnw="; - version = "2.0"; - }; - }; + dxvk32 = if stdenv.isDarwin then pkgsCross.mingw32.dxvk_1 else pkgsCross.mingw32.dxvk_2; + dxvk64 = if stdenv.isDarwin then pkgsCross.mingwW64.dxvk_1 else pkgsCross.mingwW64.dxvk_2; in { name = "dxvk"; - inherit (srcs."${system}" or srcs.default) version; - - src = fetchFromGitHub { - owner = "doitsujin"; - repo = "dxvk"; - inherit (srcs."${system}" or srcs.default) rev hash; - }; - - # Override this to patch DXVK itself (rather than the setup script). - dxvkPatches = lib.optionals stdenvNoCC.isDarwin [ - # Patch DXVK to work with MoltenVK even though it doesn’t support some required features. - # Some games work poorly (particularly Unreal Engine 4 games), but others work pretty well. - ./darwin-dxvk-compat.patch - # Use synchronization primitives from the C++ standard library to avoid deadlocks on Darwin. - # See: https://www.reddit.com/r/macgaming/comments/t8liua/comment/hzsuce9/ - ./darwin-thread-primitives.patch - ]; + inherit (dxvk64) version; outputs = [ "out" "bin" "lib" ]; + dontUnpack = true; dontConfigure = true; dontBuild = true; diff --git a/pkgs/misc/dxvk/dxvk.nix b/pkgs/misc/dxvk/dxvk.nix index 7607c9ee4412..9e00ecc343a7 100644 --- a/pkgs/misc/dxvk/dxvk.nix +++ b/pkgs/misc/dxvk/dxvk.nix @@ -5,28 +5,56 @@ , meson , ninja , windows -, src -, version +, dxvkVersion , spirv-headers , vulkan-headers -, dxvkPatches }: let # DXVK 2.0+ no longer vendors certain dependencies. This derivation also needs to build on Darwin, # which does not currently support DXVK 2.0, so adapt conditionally for this situation. - isDxvk2 = lib.versionAtLeast version "2.0"; + isDxvk2 = lib.versionAtLeast (srcs.${dxvkVersion}.version) "2.0"; + + # DXVK has effectively the same build script regardless of platform. + srcs = { + "1.10" = rec { + version = "1.10.3"; + src = fetchFromGitHub { + owner = "doitsujin"; + repo = "dxvk"; + rev = "v${version}"; + hash = "sha256-T93ZylxzJGprrP+j6axZwl2d3hJowMCUOKNjIyNzkmE="; + }; + # These patches are required when using DXVK with Wine on Darwin. + patches = lib.optionals stdenv.buildPlatform.isDarwin [ + # Patch DXVK to work with MoltenVK even though it doesn’t support some required features. + # Some games work poorly (particularly Unreal Engine 4 games), but others work pretty well. + ./darwin-dxvk-compat.patch + # Use synchronization primitives from the C++ standard library to avoid deadlocks on Darwin. + # See: https://www.reddit.com/r/macgaming/comments/t8liua/comment/hzsuce9/ + ./darwin-thread-primitives.patch + ]; + }; + "2.0" = rec { + version = "2.0"; + src = fetchFromGitHub { + owner = "doitsujin"; + repo = "dxvk"; + rev = "v${version}"; + hash = "sha256-mboVLdPgZMzmqyeF0jAloEz6xqfIDiY/X98e7l2KZnw="; + }; + patches = [ ]; + }; + }; in stdenv.mkDerivation { pname = "dxvk"; - inherit src version; + inherit (srcs.${dxvkVersion}) version src patches; nativeBuildInputs = [ glslang meson ninja ]; buildInputs = [ windows.pthreads ] ++ lib.optionals isDxvk2 [ spirv-headers vulkan-headers ]; - patches = dxvkPatches; - preConfigure = lib.optionalString isDxvk2 '' ln -s ${lib.getDev spirv-headers}/include include/spirv/include ln -s ${lib.getDev vulkan-headers}/include include/vulkan/include diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 235b6c1229b3..0d09810ef2ff 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -37209,6 +37209,8 @@ with pkgs; dump = callPackage ../tools/backup/dump { }; dxvk = callPackage ../misc/dxvk { }; + dxvk_1 = callPackage ../misc/dxvk/dxvk.nix { dxvkVersion = "1.10"; }; + dxvk_2 = callPackage ../misc/dxvk/dxvk.nix { dxvkVersion = "2.0"; }; ecdsatool = callPackage ../tools/security/ecdsatool { };