nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 cmake,
6 ninja,
7 python3,
8 git,
9}:
10
11stdenv.mkDerivation (finalAttrs: {
12 pname = "directx-shader-compiler";
13 version = "1.8.2505.1";
14
15 # Put headers in dev, there are lot of them which aren't necessary for
16 # using the compiler binary.
17 outputs = [
18 "out"
19 "dev"
20 ];
21
22 src = fetchFromGitHub {
23 owner = "microsoft";
24 repo = "DirectXShaderCompiler";
25 rev = "v${finalAttrs.version}";
26 hash = "sha256-d8qJ9crS5CStbsGOe/OSHtUEV4vr3sLCQp+6KsEq/A4=";
27 fetchSubmodules = true;
28 };
29
30 nativeBuildInputs = [
31 cmake
32 git
33 ninja
34 python3
35 ];
36
37 cmakeFlags = [ "-C../cmake/caches/PredefinedParams.cmake" ];
38
39 # The default install target installs heaps of LLVM stuff.
40 #
41 # Upstream issue: https://github.com/microsoft/DirectXShaderCompiler/issues/3276
42 #
43 # The following is based on the CI script:
44 # https://github.com/microsoft/DirectXShaderCompiler/blob/master/appveyor.yml#L63-L66
45 installPhase = ''
46 runHook preInstall
47 mkdir -p $out/bin $out/lib $dev/include
48 mv bin/{dxc,dxv}* $out/bin/
49 mv lib/lib*.so* lib/lib*.*dylib $out/lib/
50 cp -r $src/include/dxc $dev/include/
51 runHook postInstall
52 '';
53
54 meta = {
55 description = "Compiler to compile HLSL programs into DXIL and SPIR-V";
56 homepage = "https://github.com/microsoft/DirectXShaderCompiler";
57 platforms = with lib.platforms; linux ++ darwin;
58 license = lib.licenses.ncsa;
59 maintainers = with lib.maintainers; [ Flakebi ];
60 };
61})