systemd: add missing patch for Musl
[NixPkgs.git] / pkgs / development / compilers / shaderc / default.nix
blobcbbb42b62cfc5d40186a697fcf9dc94bbe8c3d68
2   lib,
3   stdenv,
4   fetchFromGitHub,
5   cmake,
6   python3,
7   autoSignDarwinBinariesHook,
8   cctools,
9 }:
10 # Like many google projects, shaderc doesn't gracefully support separately compiled dependencies, so we can't easily use
11 # the versions of glslang and spirv-tools used by vulkan-loader. Exact revisions are taken from
12 # https://github.com/google/shaderc/blob/known-good/known_good.json
14 # Future work: extract and fetch all revisions automatically based on a revision of shaderc's known-good branch.
15 let
16   glslang = fetchFromGitHub {
17     owner = "KhronosGroup";
18     repo = "glslang";
19     rev = "6be56e45e574b375d759b89dad35f780bbd4792f";
20     hash = "sha256-tktdsj4sxwQHBavHzu1x8H28RrIqSQs/fp2TQcVCm2g=";
21   };
22   spirv-tools = fetchFromGitHub {
23     owner = "KhronosGroup";
24     repo = "SPIRV-Tools";
25     rev = "360d469b9eac54d6c6e20f609f9ec35e3a5380ad";
26     hash = "sha256-Bned5Pa6zCFByfNvqD0M5t3l4uAJYkDlpe6wu8e7a3U=";
27   };
28   spirv-headers = fetchFromGitHub {
29     owner = "KhronosGroup";
30     repo = "SPIRV-Headers";
31     rev = "4183b260f4cccae52a89efdfcdd43c4897989f42";
32     hash = "sha256-RKjw3H1z02bl6730xsbo38yjMaOCsHZP9xJOQbmWpnw=";
33   };
35 stdenv.mkDerivation rec {
36   pname = "shaderc";
37   version = "2024.0";
39   outputs = [
40     "out"
41     "lib"
42     "bin"
43     "dev"
44     "static"
45   ];
47   src = fetchFromGitHub {
48     owner = "google";
49     repo = "shaderc";
50     rev = "v${version}";
51     hash = "sha256-Cwp7WbaKWw/wL9m70wfYu47xoUGQW+QGeoYhbyyzstQ=";
52   };
54   postPatch = ''
55     cp -r --no-preserve=mode ${glslang} third_party/glslang
56     cp -r --no-preserve=mode ${spirv-tools} third_party/spirv-tools
57     ln -s ${spirv-headers} third_party/spirv-tools/external/spirv-headers
58     patchShebangs --build utils/
59   '';
61   nativeBuildInputs =
62     [
63       cmake
64       python3
65     ]
66     ++ lib.optionals stdenv.hostPlatform.isDarwin [ cctools ]
67     ++ lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) [
68       autoSignDarwinBinariesHook
69     ];
71   postInstall = ''
72     moveToOutput "lib/*.a" $static
73   '';
75   cmakeFlags = [ "-DSHADERC_SKIP_TESTS=ON" ];
77   # Fix the paths in .pc, even though it's unclear if all these .pc are really useful.
78   postFixup = ''
79     substituteInPlace "$dev"/lib/pkgconfig/*.pc \
80       --replace '=''${prefix}//' '=/' \
81       --replace "$dev/$dev/" "$dev/"
82   '';
84   meta = with lib; {
85     inherit (src.meta) homepage;
86     description = "Collection of tools, libraries and tests for shader compilation";
87     platforms = platforms.all;
88     license = [ licenses.asl20 ];
89   };