about summary refs log tree commit diff
path: root/pkgs
diff options
context:
space:
mode:
authorJoe Hermaszewski <git@monoid.al>2020-11-20 16:24:40 +0800
committerJoe Hermaszewski <git@monoid.al>2020-12-19 14:18:02 +0800
commitcb43266d22d6b0f52313c5ac5e28ef66dfeca90c (patch)
tree8a55696e2a241a3c436b193b634f5566645c65a2 /pkgs
parent41c8f3c356ea8af2c3db3c83bc8a64416f641b58 (diff)
directx-shader-compiler: init at 1.5.2010
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/tools/graphics/directx-shader-compiler/default.nix50
-rw-r--r--pkgs/top-level/all-packages.nix2
2 files changed, 52 insertions, 0 deletions
diff --git a/pkgs/tools/graphics/directx-shader-compiler/default.nix b/pkgs/tools/graphics/directx-shader-compiler/default.nix
new file mode 100644
index 0000000000000..13665b776469f
--- /dev/null
+++ b/pkgs/tools/graphics/directx-shader-compiler/default.nix
@@ -0,0 +1,50 @@
+{ stdenv, fetchFromGitHub, cmake, python3, git }:
+
+stdenv.mkDerivation rec {
+  pname = "directx-shader-compiler";
+  version = "1.5.2010";
+
+  # Put headers in dev, there are lot of them which aren't necessary for
+  # using the compiler binary.
+  outputs = [ "out" "dev" ];
+
+  src = fetchFromGitHub {
+    owner = "microsoft";
+    repo = "DirectXShaderCompiler";
+    rev = "v${version}";
+    sha256 = "0ccfy1bfp0cm0pq63ri4yl1sr3fdn1a526bsnakg4bl6z4fwrnnj";
+    # We rely on the side effect of leaving the .git directory here for the
+    # version-grabbing functionality of the build system.
+    fetchSubmodules = true;
+  };
+
+  nativeBuildInputs = [ cmake git python3 ];
+
+  configurePhase = ''
+    # Requires some additional flags to cmake from a file in the repo
+    additionalCMakeFlags=$(< utils/cmake-predefined-config-params)
+    cmakeFlags="$additionalCMakeFlags''${cmakeFlags:+ $cmakeFlags}"
+    cmakeConfigurePhase
+  '';
+
+  # The default install target installs heaps of LLVM stuff.
+  #
+  # Upstream issue: https://github.com/microsoft/DirectXShaderCompiler/issues/3276
+  #
+  # The following is based on the CI script:
+  # https://github.com/microsoft/DirectXShaderCompiler/blob/master/appveyor.yml#L63-L66
+  installPhase = ''
+    mkdir -p $out/bin $out/lib $dev/include
+    mv bin/dxc* $out/bin/
+    mv lib/libdxcompiler.so* $out/lib/
+    cp -r $src/include/dxc $dev/include/
+  '';
+
+  meta = with stdenv.lib; {
+    description = "A compiler to compile HLSL programs into DXIL and SPIR-V";
+    homepage = "https://github.com/microsoft/DirectXShaderCompiler";
+    platforms = platforms.linux;
+    license = licenses.ncsa;
+    maintainers = with maintainers; [ expipiplus1 ];
+  };
+}
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index 0c7c2919ec3ce..4d580aa51f7b1 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -16982,6 +16982,8 @@ in
 
   diod = callPackage ../servers/diod { lua = lua5_1; };
 
+  directx-shader-compiler = callPackage ../tools/graphics/directx-shader-compiler {};
+
   dkimproxy = callPackage ../servers/mail/dkimproxy { };
 
   do-agent = callPackage ../servers/monitoring/do-agent { };