Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ lib, stdenv, fetchgit, python3, cmake, jq, libX11, libXext, zlib }: 2 3stdenv.mkDerivation rec { 4 pname = "swiftshader"; 5 version = "2020-11-06"; 6 7 src = fetchgit { 8 url = "https://swiftshader.googlesource.com/SwiftShader"; 9 rev = "4ed9d3498dcffa987acba1a8007ff8dec336f263"; 10 sha256 = "1gz2zflfacxf34s78djddf93brn9kyxj4byc4p2ip1pin43lh2lg"; 11 }; 12 13 nativeBuildInputs = [ cmake python3 jq ]; 14 buildInputs = [ libX11 libXext zlib ]; 15 16 env.NIX_CFLAGS_COMPILE = toString [ 17 # Needed with GCC 12 18 "-Wno-error=array-bounds" 19 "-Wno-error=uninitialized" 20 ]; 21 22 # Make sure we include the drivers and icd files in the output as the cmake 23 # generated install command only puts in the spirv-tools stuff. 24 installPhase = '' 25 runHook preInstall 26 27 # 28 # Vulkan driver 29 # 30 vk_so_path="$out/lib/libvk_swiftshader.so" 31 mkdir -p "$(dirname "$vk_so_path")" 32 mv Linux/libvk_swiftshader.so "$vk_so_path" 33 34 vk_icd_json="$out/share/vulkan/icd.d/vk_swiftshader_icd.json" 35 mkdir -p "$(dirname "$vk_icd_json")" 36 jq ".ICD.library_path = \"$vk_so_path\"" <Linux/vk_swiftshader_icd.json >"$vk_icd_json" 37 38 # 39 # GL driver 40 # 41 gl_so_path="$out/lib/libEGL.so" 42 mkdir -p "$(dirname "$gl_so_path")" 43 mv Linux/libEGL.so "$gl_so_path" 44 45 gl_icd_json="$out/share/glvnd/egl_vendor.d/swiftshader.json" 46 mkdir -p "$(dirname "$gl_icd_json")" 47 cat >"$gl_icd_json" <<EOF 48 { 49 "file_format_version" : "1.0.0", 50 "ICD" : { 51 "library_path" : "$gl_so_path" 52 } 53 } 54 EOF 55 56 runHook postInstall 57 ''; 58 59 meta = with lib; { 60 description = 61 "A high-performance CPU-based implementation of the Vulkan, OpenGL ES, and Direct3D 9 graphics APIs"; 62 homepage = "https://opensource.google/projects/swiftshader"; 63 license = licenses.asl20; 64 # Should be possible to support Darwin by changing the install phase with 65 # 's/Linux/Darwin/' and 's/so/dylib/' or something similar. 66 platforms = [ "i686-linux" "x86_64-linux" "armv7l-linux" "mipsel-linux" ]; 67 maintainers = with maintainers; [ expipiplus1 ]; 68 }; 69}