nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 88 lines 2.1 kB view raw
1{ 2 lib, 3 stdenv, 4 cmake, 5 pkg-config, 6 ninja, 7 makeWrapper, 8 wgpu-native, 9 glfw, 10 wayland, 11 libxrandr, 12 libx11, 13 vulkan-loader, 14 15 version, 16 src, 17}: 18 19stdenv.mkDerivation (finalAttrs: { 20 inherit version src; 21 pname = "wgpu-native-examples"; 22 23 sourceRoot = "${src.name}/examples"; 24 25 postPatch = '' 26 substituteInPlace ./CMakeLists.txt \ 27 --replace-fail 'add_subdirectory(vendor/glfw)' 'find_package(glfw3 3.4 REQUIRED)' 28 ''; 29 30 strictDeps = true; 31 32 nativeBuildInputs = [ 33 cmake 34 pkg-config 35 ninja 36 makeWrapper 37 ]; 38 39 buildInputs = [ 40 wgpu-native 41 glfw 42 ] 43 ++ lib.optionals stdenv.hostPlatform.isLinux [ 44 wayland 45 libx11 46 libxrandr 47 ]; 48 49 runtimeInputs = lib.optionals stdenv.hostPlatform.isLinux [ 50 # Without wayland in library path, this warning is raised: 51 # "No windowing system present. Using surfaceless platform" 52 wayland 53 # Without vulkan-loader present, wgpu won't find any adapter 54 vulkan-loader 55 ]; 56 57 makeWrapperArgs = lib.optionals (finalAttrs.runtimeInputs != [ ]) [ 58 "--prefix LD_LIBRARY_PATH : ${toString (lib.makeLibraryPath finalAttrs.runtimeInputs)}" 59 ]; 60 61 installPhase = '' 62 runHook preInstall 63 64 concatTo makeWrapperArgsArray makeWrapperArgs 65 66 # find all executables that have the same name as their directory 67 for executable in $(find . -regex '.*\(/[^/]*\)\1' -type f -executable) 68 do 69 target="$(basename "$(dirname "$executable")")" 70 install -Dm755 $executable -t $out/bin 71 mkdir -p $out/share/$target 72 wrapProgram $out/bin/$target --chdir $out/share/$target "''${makeWrapperArgsArray[@]}" 73 74 # The examples expect their shaders in the CWD, so we copy them into the store 75 # and wrap the examples to run in the directory containing the shader. 76 for shader in $(find ../$target -type f -name '*.wgsl'); do 77 install -Dm644 $shader $out/share/$target/ 78 done 79 done 80 81 runHook postInstall 82 ''; 83 84 meta = wgpu-native.meta // { 85 description = "Examples for the native WebGPU implementation based on wgpu-core"; 86 mainProgram = "triangle"; 87 }; 88})