dxvk: expose Windows derivations

This is in preparation for native builds of DXVK, but it also allows
users to choose to use an older version if that is more compatible with
their hardware.
This commit is contained in:
Randy Eckenrode 2023-01-26 23:23:26 -05:00
parent 16e9b55025
commit 403fe21323
No known key found for this signature in database
GPG key ID: 64C1CD4EC2A600D9
3 changed files with 42 additions and 51 deletions

View file

@ -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 its 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 doesnt 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;

View file

@ -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 doesnt 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

View file

@ -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 { };