3
0
Fork 0
forked from mirrors/nixpkgs
nixpkgs/pkgs/misc/dxvk/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

90 lines
3.3 KiB
Nix
Raw Normal View History

2022-02-14 16:08:03 +00:00
{ lib
, pkgs
, hostPlatform
, stdenvNoCC
2022-02-14 16:08:03 +00:00
, fetchFromGitHub
, pkgsCross
}:
stdenvNoCC.mkDerivation (finalAttrs:
let
inherit (hostPlatform.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 {
2022-11-11 00:41:42 +00:00
darwin = {
rev = "v${finalAttrs.version}";
2022-07-15 13:37:13 +01:00
hash = "sha256-T93ZylxzJGprrP+j6axZwl2d3hJowMCUOKNjIyNzkmE=";
version = "1.10.3";
};
2022-11-11 00:41:42 +00:00
default = {
rev = "v${finalAttrs.version}";
hash = "sha256-mboVLdPgZMzmqyeF0jAloEz6xqfIDiY/X98e7l2KZnw=";
version = "2.0";
};
};
in
{
2022-02-14 16:08:03 +00:00
name = "dxvk";
inherit (srcs."${system}" or srcs.default) version;
2022-02-14 16:08:03 +00:00
src = fetchFromGitHub {
owner = "doitsujin";
repo = "dxvk";
inherit (srcs."${system}" or srcs.default) rev hash;
2022-02-14 16:08:03 +00:00
};
# 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
];
2022-02-14 16:08:03 +00:00
outputs = [ "out" "bin" "lib" ];
# Also copy `mcfgthread-12.dll` due to DXVKs being built in a MinGW cross environment.
patches = [ ./mcfgthread.patch ];
dontConfigure = true;
dontBuild = true;
installPhase = ''
mkdir -p $out/bin $bin $lib
2022-11-11 00:41:42 +00:00
# Replace both basedir forms to support both DXVK 2.0 and older versions.
2022-02-14 16:08:03 +00:00
substitute setup_dxvk.sh $out/bin/setup_dxvk.sh \
--subst-var-by mcfgthreads32 "${pkgsCross.mingw32.windows.mcfgthreads}" \
--subst-var-by mcfgthreads64 "${pkgsCross.mingwW64.windows.mcfgthreads}" \
2022-11-11 00:41:42 +00:00
--replace 'basedir=$(dirname "$(readlink -f $0)")' "basedir=$bin" \
--replace 'basedir="$(dirname "$(readlink -f "$0")")"' "basedir=$bin"
2022-02-14 16:08:03 +00:00
chmod a+x $out/bin/setup_dxvk.sh
declare -A dxvks=( [x32]=${dxvk32} [x64]=${dxvk64} )
for arch in "''${!dxvks[@]}"; do
ln -s "''${dxvks[$arch]}/bin" $bin/$arch
ln -s "''${dxvks[$arch]}/lib" $lib/$arch
done
'';
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;
2022-06-01 21:47:56 +01:00
platforms = [ "x86_64-darwin" "i686-linux" "x86_64-linux" ];
2022-02-14 16:08:03 +00:00
};
})