about summary refs log tree commit diff
path: root/nixpkgs/pkgs/by-name/dx/dxvk_2/package.nix
blob: e1fa64ffee05b58b953f7459e21e39cc3401fc39 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
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;
  };
})