@@ -0,0 +1,50 @@
1+{ stdenv, fetchFromGitHub, cmake, python3, git }:
2+
3+stdenv.mkDerivation rec {
4+ pname = "directx-shader-compiler";
5+ version = "1.5.2010";
6+
7+ # Put headers in dev, there are lot of them which aren't necessary for
8+ # using the compiler binary.
9+ outputs = [ "out" "dev" ];
10+
11+ src = fetchFromGitHub {
12+ owner = "microsoft";
13+ repo = "DirectXShaderCompiler";
14+ rev = "v${version}";
15+ sha256 = "0ccfy1bfp0cm0pq63ri4yl1sr3fdn1a526bsnakg4bl6z4fwrnnj";
16+ # We rely on the side effect of leaving the .git directory here for the
17+ # version-grabbing functionality of the build system.
18+ fetchSubmodules = true;
19+ };
20+
21+ nativeBuildInputs = [ cmake git python3 ];
22+
23+ configurePhase = ''
24+ # Requires some additional flags to cmake from a file in the repo
25+ additionalCMakeFlags=$(< utils/cmake-predefined-config-params)
26+ cmakeFlags="$additionalCMakeFlags''${cmakeFlags:+ $cmakeFlags}"
27+ cmakeConfigurePhase
28+ '';
29+
30+ # The default install target installs heaps of LLVM stuff.
31+ #
32+ # Upstream issue: https://github.com/microsoft/DirectXShaderCompiler/issues/3276
33+ #
34+ # The following is based on the CI script:
35+ # https://github.com/microsoft/DirectXShaderCompiler/blob/master/appveyor.yml#L63-L66
36+ installPhase = ''
37+ mkdir -p $out/bin $out/lib $dev/include
38+ mv bin/dxc* $out/bin/
39+ mv lib/libdxcompiler.so* $out/lib/
40+ cp -r $src/include/dxc $dev/include/
41+ '';
42+
43+ meta = with stdenv.lib; {
44+ description = "A compiler to compile HLSL programs into DXIL and SPIR-V";
45+ homepage = "https://github.com/microsoft/DirectXShaderCompiler";
46+ platforms = platforms.linux;
47+ license = licenses.ncsa;
48+ maintainers = with maintainers; [ expipiplus1 ];
49+ };
50+}