Merge pull request #268619 from tweag/lib-descriptions
[NixPkgs.git] / pkgs / development / libraries / openxr-loader / default.nix
blob53bfa41a8e25328e99caba2f6c0448cf5f3ee32b
1 { lib, stdenv, fetchFromGitHub, cmake, python3, libX11, libXxf86vm, libXrandr, vulkan-headers, libGL, vulkan-loader, wayland, pkg-config }:
3 stdenv.mkDerivation rec {
4   pname = "openxr-loader";
5   version = "1.0.31";
7   src = fetchFromGitHub {
8     owner = "KhronosGroup";
9     repo = "OpenXR-SDK-Source";
10     rev = "release-${version}";
11     sha256 = "sha256-qK8l/v6nLuMAitz7DfVDjJyVjEmkeD2jgJkG5qOMCcQ=";
12   };
14   nativeBuildInputs = [ cmake python3 pkg-config ];
15   buildInputs = [ libX11 libXxf86vm libXrandr vulkan-headers libGL vulkan-loader wayland ];
17   cmakeFlags = [ "-DBUILD_TESTS=ON" ];
19   outputs = [ "out" "dev" "layers" ];
21   # https://github.com/KhronosGroup/OpenXR-SDK-Source/issues/305
22   postPatch = ''
23     substituteInPlace src/loader/openxr.pc.in \
24       --replace '$'{exec_prefix}/@CMAKE_INSTALL_LIBDIR@ @CMAKE_INSTALL_FULL_LIBDIR@
25   '';
27   postInstall = ''
28     mkdir -p "$layers/share"
29     mv "$out/share/openxr" "$layers/share"
30     # Use absolute paths in manifests so no LD_LIBRARY_PATH shenanigans are necessary
31     for file in "$layers/share/openxr/1/api_layers/explicit.d/"*; do
32         substituteInPlace "$file" --replace '"library_path": "lib' "\"library_path\": \"$layers/lib/lib"
33     done
34     mkdir -p "$layers/lib"
35     mv "$out/lib/libXrApiLayer"* "$layers/lib"
36   '';
38   meta = with lib; {
39     description = "Khronos OpenXR loader";
40     homepage    = "https://www.khronos.org/openxr";
41     platforms   = platforms.linux;
42     license     = licenses.asl20;
43     maintainers = [ maintainers.ralith ];
44   };