From 26f624d94005301cc2dcbfcd3a161e7c0151e6fb Mon Sep 17 00:00:00 2001 From: Randy Eckenrode Date: Sun, 8 Oct 2023 15:58:27 -0400 Subject: [PATCH] dxvk: migrate to by-name --- .../dx/dxvk/package.nix} | 0 pkgs/{misc => by-name/dx}/dxvk/setup_dxvk.sh | 0 .../dx/dxvk_1}/darwin-dxvk-compat.patch | 0 .../dx/dxvk_1}/darwin-thread-primitives.patch | 0 pkgs/by-name/dx/dxvk_1/package.nix | 57 +++++++++ pkgs/by-name/dx/dxvk_2/package.nix | 77 ++++++++++++ pkgs/misc/dxvk/dxvk.nix | 114 ------------------ pkgs/top-level/all-packages.nix | 4 - 8 files changed, 134 insertions(+), 118 deletions(-) rename pkgs/{misc/dxvk/default.nix => by-name/dx/dxvk/package.nix} (100%) rename pkgs/{misc => by-name/dx}/dxvk/setup_dxvk.sh (100%) rename pkgs/{misc/dxvk => by-name/dx/dxvk_1}/darwin-dxvk-compat.patch (100%) rename pkgs/{misc/dxvk => by-name/dx/dxvk_1}/darwin-thread-primitives.patch (100%) create mode 100644 pkgs/by-name/dx/dxvk_1/package.nix create mode 100644 pkgs/by-name/dx/dxvk_2/package.nix delete mode 100644 pkgs/misc/dxvk/dxvk.nix diff --git a/pkgs/misc/dxvk/default.nix b/pkgs/by-name/dx/dxvk/package.nix similarity index 100% rename from pkgs/misc/dxvk/default.nix rename to pkgs/by-name/dx/dxvk/package.nix diff --git a/pkgs/misc/dxvk/setup_dxvk.sh b/pkgs/by-name/dx/dxvk/setup_dxvk.sh similarity index 100% rename from pkgs/misc/dxvk/setup_dxvk.sh rename to pkgs/by-name/dx/dxvk/setup_dxvk.sh diff --git a/pkgs/misc/dxvk/darwin-dxvk-compat.patch b/pkgs/by-name/dx/dxvk_1/darwin-dxvk-compat.patch similarity index 100% rename from pkgs/misc/dxvk/darwin-dxvk-compat.patch rename to pkgs/by-name/dx/dxvk_1/darwin-dxvk-compat.patch diff --git a/pkgs/misc/dxvk/darwin-thread-primitives.patch b/pkgs/by-name/dx/dxvk_1/darwin-thread-primitives.patch similarity index 100% rename from pkgs/misc/dxvk/darwin-thread-primitives.patch rename to pkgs/by-name/dx/dxvk_1/darwin-thread-primitives.patch diff --git a/pkgs/by-name/dx/dxvk_1/package.nix b/pkgs/by-name/dx/dxvk_1/package.nix new file mode 100644 index 000000000000..44a39eeaba25 --- /dev/null +++ b/pkgs/by-name/dx/dxvk_1/package.nix @@ -0,0 +1,57 @@ +{ lib +, stdenv +, fetchFromGitHub +, glslang +, meson +, ninja +, windows +, pkgsBuildHost +, enableMoltenVKCompat ? false +}: + +let + isCross = stdenv.hostPlatform != stdenv.targetPlatform; +in +stdenv.mkDerivation (finalAttrs: { + pname = "dxvk"; + version = "1.10.3"; + + src = fetchFromGitHub { + owner = "doitsujin"; + repo = "dxvk"; + rev = "v${finalAttrs.version}"; + hash = "sha256-T93ZylxzJGprrP+j6axZwl2d3hJowMCUOKNjIyNzkmE="; + }; + + # These patches are required when using DXVK with Wine on Darwin. + patches = lib.optionals enableMoltenVKCompat [ + # 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 + ]; + + nativeBuildInputs = [ glslang meson ninja ]; + buildInputs = [ windows.pthreads ]; + + mesonFlags = + let + arch = if stdenv.is32bit then "32" else "64"; + in + [ + "--buildtype" "release" + "--prefix" "${placeholder "out"}" + ] + ++ lib.optionals isCross [ "--cross-file" "build-win${arch}.txt" ]; + + meta = { + description = "A Vulkan-based translation layer for Direct3D 9/10/11"; + homepage = "https://github.com/doitsujin/dxvk"; + changelog = "https://github.com/doitsujin/dxvk/releases"; + maintainers = [ lib.maintainers.reckenrode ]; + license = lib.licenses.zlib; + platforms = lib.platforms.windows; + }; +}) diff --git a/pkgs/by-name/dx/dxvk_2/package.nix b/pkgs/by-name/dx/dxvk_2/package.nix new file mode 100644 index 000000000000..e1fa64ffee05 --- /dev/null +++ b/pkgs/by-name/dx/dxvk_2/package.nix @@ -0,0 +1,77 @@ +{ lib +, stdenv +, fetchFromGitHub +, pkgsBuildHost +, glslang +, meson +, ninja +, windows +, spirv-headers +, vulkan-headers +, SDL2 +, glfw +, gitUpdater +, sdl2Support ? true +, glfwSupport ? false +}: + +# SDL2 and GLFW support are mutually exclusive. +assert !sdl2Support || !glfwSupport; + +let + isCross = stdenv.hostPlatform != stdenv.targetPlatform; + isWindows = stdenv.hostPlatform.uname.system == "Windows"; +in +stdenv.mkDerivation (finalAttrs: { + pname = "dxvk"; + version = "2.3"; + + src = fetchFromGitHub { + owner = "doitsujin"; + repo = "dxvk"; + rev = "v${finalAttrs.version}"; + hash = "sha256-RU+B0XfphD5HHW/vSzqHLUaGS3E31d5sOLp3lMmrCB8="; + fetchSubmodules = true; # Needed for the DirectX headers and libdisplay-info + }; + + postPatch = '' + substituteInPlace "subprojects/libdisplay-info/tool/gen-search-table.py" \ + --replace "/usr/bin/env python3" "${lib.getBin pkgsBuildHost.python3}/bin/python3" + ''; + + nativeBuildInputs = [ glslang meson ninja ]; + buildInputs = [ spirv-headers vulkan-headers ] + ++ lib.optionals (!isWindows && sdl2Support) [ SDL2 ] + ++ lib.optionals (!isWindows && glfwSupport) [ glfw ] + ++ lib.optionals isWindows [ windows.pthreads ]; + + # Build with the Vulkan SDK in nixpkgs. + preConfigure = '' + rm -rf include/spirv/include include/vulkan/include + mkdir -p include/spirv/include include/vulkan/include + ''; + + mesonFlags = + let + arch = if stdenv.is32bit then "32" else "64"; + in + [ + "--buildtype" "release" + "--prefix" "${placeholder "out"}" + ] + ++ lib.optionals isCross [ "--cross-file" "build-win${arch}.txt" ] + ++ lib.optional glfwSupport "-Ddxvk_native_wsi=glfw"; + + doCheck = !isCross; + + passthru.updateScript = gitUpdater { rev-prefix = "v"; }; + + meta = { + description = "A Vulkan-based translation layer for Direct3D 9/10/11"; + homepage = "https://github.com/doitsujin/dxvk"; + changelog = "https://github.com/doitsujin/dxvk/releases"; + maintainers = [ lib.maintainers.reckenrode ]; + license = lib.licenses.zlib; + platforms = lib.platforms.windows ++ lib.platforms.linux; + }; +}) diff --git a/pkgs/misc/dxvk/dxvk.nix b/pkgs/misc/dxvk/dxvk.nix deleted file mode 100644 index 129090faaf47..000000000000 --- a/pkgs/misc/dxvk/dxvk.nix +++ /dev/null @@ -1,114 +0,0 @@ -{ lib -, stdenv -, fetchFromGitHub -, glslang -, meson -, ninja -, windows -, dxvkVersion ? "default" -, spirv-headers -, vulkan-headers -, SDL2 -, glfw -, pkgsBuildHost -, gitUpdater -, sdl2Support ? true -, glfwSupport ? false -, enableMoltenVKCompat ? false -}: - -# SDL2 and GLFW support are mutually exclusive. -assert !sdl2Support || !glfwSupport; - -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 (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 enableMoltenVKCompat [ - # 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 - ]; - }; - "default" = rec { - version = "2.3"; - src = fetchFromGitHub { - owner = "doitsujin"; - repo = "dxvk"; - rev = "v${version}"; - hash = "sha256-RU+B0XfphD5HHW/vSzqHLUaGS3E31d5sOLp3lMmrCB8="; - fetchSubmodules = true; # Needed for the DirectX headers and libdisplay-info - }; - patches = [ ]; - }; - }; - - isWindows = stdenv.targetPlatform.uname.system == "Windows"; - isCross = stdenv.hostPlatform != stdenv.targetPlatform; -in -stdenv.mkDerivation (finalAttrs: { - pname = "dxvk"; - inherit (srcs.${dxvkVersion}) version src patches; - - nativeBuildInputs = [ glslang meson ninja ]; - buildInputs = lib.optionals isWindows [ windows.pthreads ] - ++ lib.optionals isDxvk2 ( - [ spirv-headers vulkan-headers ] - ++ lib.optional (!isWindows && sdl2Support) SDL2 - ++ lib.optional (!isWindows && glfwSupport) glfw - ); - - postPatch = lib.optionalString isDxvk2 '' - substituteInPlace "subprojects/libdisplay-info/tool/gen-search-table.py" \ - --replace "/usr/bin/env python3" "${lib.getBin pkgsBuildHost.python3}/bin/python3" - ''; - - # Build with the Vulkan SDK in nixpkgs. - preConfigure = '' - rm -rf include/spirv/include include/vulkan/include - mkdir -p include/spirv/include include/vulkan/include - ''; - - mesonFlags = - let - arch = if stdenv.is32bit then "32" else "64"; - in - [ - "--buildtype" "release" - "--prefix" "${placeholder "out"}" - ] - ++ lib.optionals isCross [ "--cross-file" "build-win${arch}.txt" ] - ++ lib.optional glfwSupport "-Ddxvk_native_wsi=glfw"; - - doCheck = isDxvk2 && !isCross; - - passthru = lib.optionalAttrs (lib.versionAtLeast finalAttrs.version "2.0") { - updateScript = gitUpdater { - rev-prefix = "v"; - }; - }; - - meta = { - description = "A Vulkan-based translation layer for Direct3D 9/10/11"; - homepage = "https://github.com/doitsujin/dxvk"; - changelog = "https://github.com/doitsujin/dxvk/releases"; - maintainers = [ lib.maintainers.reckenrode ]; - license = lib.licenses.zlib; - platforms = lib.platforms.windows ++ lib.optionals isDxvk2 lib.platforms.linux; - }; -}) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index c527c613c979..6bbe37227b44 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -40458,10 +40458,6 @@ 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 { }; - ec2stepshell = callPackage ../tools/security/ec2stepshell { }; ecdsatool = callPackage ../tools/security/ecdsatool { };