at master 2.7 kB view raw
1{ 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 11# compiled dependencies, so we can't easily use the versions of glslang and 12# spirv-tools used by vulkan-loader. Exact revisions are taken from 13# https://github.com/google/shaderc/blob/known-good/known_good.json 14 15# Future work: extract and fetch all revisions automatically based on a revision 16# of shaderc's known-good branch. 17let 18 glslang = fetchFromGitHub { 19 owner = "KhronosGroup"; 20 repo = "glslang"; 21 # No corresponding tag for efd24d75bcbc55620e759f6bf42c45a32abac5f8 on 2025-06-23 22 rev = "efd24d75bcbc55620e759f6bf42c45a32abac5f8"; 23 hash = "sha256-wMd1ylwDOM/uBbhpyMAduM9X7ao08TNq3HdoNGfSjcQ="; 24 }; 25 spirv-tools = fetchFromGitHub { 26 owner = "KhronosGroup"; 27 repo = "SPIRV-Tools"; 28 rev = "v2025.3.rc1"; 29 hash = "sha256-yAdd/mXY8EJnE0vCu0n/aVxMH9059T/7cAdB9nP1vQQ="; 30 }; 31 spirv-headers = fetchFromGitHub { 32 owner = "KhronosGroup"; 33 repo = "SPIRV-Headers"; 34 # No corresponding tag for 2a611a970fdbc41ac2e3e328802aed9985352dca on 2025-06-19 35 rev = "2a611a970fdbc41ac2e3e328802aed9985352dca"; 36 hash = "sha256-LRjMy9xtOErbJbMh+g2IKXfmo/hWpegZM72F8E122oY="; 37 }; 38in 39stdenv.mkDerivation (finalAttrs: { 40 pname = "shaderc"; 41 version = "2025.3"; 42 43 outputs = [ 44 "out" 45 "lib" 46 "bin" 47 "dev" 48 "static" 49 ]; 50 51 src = fetchFromGitHub { 52 owner = "google"; 53 repo = "shaderc"; 54 rev = "v${finalAttrs.version}"; 55 hash = "sha256-q5Z0wER8DbkmfT/MNrmnn9J9rzur2YjzAncaO1aRNXA="; 56 }; 57 58 postPatch = '' 59 cp -r --no-preserve=mode ${glslang} third_party/glslang 60 cp -r --no-preserve=mode ${spirv-tools} third_party/spirv-tools 61 ln -s ${spirv-headers} third_party/spirv-tools/external/spirv-headers 62 patchShebangs --build utils/ 63 ''; 64 65 nativeBuildInputs = [ 66 cmake 67 python3 68 ] 69 ++ lib.optionals stdenv.hostPlatform.isDarwin [ cctools ] 70 ++ lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) [ 71 autoSignDarwinBinariesHook 72 ]; 73 74 postInstall = '' 75 moveToOutput "lib/*.a" $static 76 ''; 77 78 cmakeFlags = [ "-DSHADERC_SKIP_TESTS=ON" ]; 79 80 # Fix the paths in .pc, even though it's unclear if all these .pc are really useful. 81 postFixup = '' 82 substituteInPlace "$dev"/lib/pkgconfig/*.pc \ 83 --replace-fail '=''${prefix}//' '=/' \ 84 --replace-fail "$dev/$dev/" "$dev/" 85 ''; 86 87 meta = { 88 description = "Collection of tools, libraries and tests for shader compilation"; 89 inherit (finalAttrs.src.meta) homepage; 90 license = lib.licenses.asl20; 91 platforms = lib.platforms.all; 92 }; 93})