base16-schemes: unstable-2024-06-21 -> unstable-2024-11-12
[NixPkgs.git] / pkgs / by-name / al / alvr / package.nix
blobe1904ab6deff25915883b837c7c4491f5d37fd8c
2   lib,
3   rustPlatform,
4   fetchFromGitHub,
5   substituteAll,
6   nix-update-script,
7   pkg-config,
8   autoAddDriverRunpath,
9   alsa-lib,
10   brotli,
11   bzip2,
12   celt,
13   ffmpeg,
14   jack2,
15   lame,
16   libX11,
17   libXi,
18   libXrandr,
19   libXcursor,
20   libdrm,
21   libglvnd,
22   libogg,
23   libpng,
24   libtheora,
25   libunwind,
26   libva,
27   libvdpau,
28   libxkbcommon,
29   openssl,
30   openvr,
31   pipewire,
32   rust-cbindgen,
33   soxr,
34   vulkan-headers,
35   vulkan-loader,
36   wayland,
37   x264,
38   xvidcore,
41 rustPlatform.buildRustPackage rec {
42   pname = "alvr";
43   version = "20.11.0";
45   src = fetchFromGitHub {
46     owner = "alvr-org";
47     repo = "ALVR";
48     rev = "refs/tags/v${version}";
49     fetchSubmodules = true; #TODO devendor openvr
50     hash = "sha256-zqeh9U0A/KHlRieq9Lf+7f04K3JG/vpE2gZ916ReXLc=";
51   };
53   cargoLock = {
54     lockFile = ./Cargo.lock;
55     outputHashes = {
56       "openxr-0.19.0" = "sha256-bnMSjJh+zjLw4Pdxr7LLm6qYAJOK7hz5xORKZ2pVcGw=";
57       "settings-schema-0.2.0" = "sha256-luEdAKDTq76dMeo5kA+QDTHpRMFUg3n0qvyQ7DkId0k=";
58     };
59   };
61   patches = [
62     (substituteAll {
63       src = ./fix-finding-libs.patch;
64       ffmpeg = lib.getDev ffmpeg;
65       x264 = lib.getDev x264;
66     })
67   ];
69   env = {
70     NIX_CFLAGS_COMPILE = toString [
71       "-lbrotlicommon"
72       "-lbrotlidec"
73       "-lcrypto"
74       "-lpng"
75       "-lssl"
76     ];
77   };
79   RUSTFLAGS = map (a: "-C link-arg=${a}") [
80     "-Wl,--push-state,--no-as-needed"
81     "-lEGL"
82     "-lwayland-client"
83     "-lxkbcommon"
84     "-Wl,--pop-state"
85   ];
87   nativeBuildInputs = [
88     rust-cbindgen
89     pkg-config
90     rustPlatform.bindgenHook
91     autoAddDriverRunpath
92   ];
94   buildInputs = [
95     alsa-lib
96     brotli
97     bzip2
98     celt
99     ffmpeg
100     jack2
101     lame
102     libX11
103     libXcursor
104     libXi
105     libXrandr
106     libdrm
107     libglvnd
108     libogg
109     libpng
110     libtheora
111     libunwind
112     libva
113     libvdpau
114     libxkbcommon
115     openssl
116     openvr
117     pipewire
118     soxr
119     vulkan-headers
120     vulkan-loader
121     wayland
122     x264
123     xvidcore
124   ];
126   postBuild = ''
127     # Build SteamVR driver ("streamer")
128     cargo xtask build-streamer --release
129   '';
131   postInstall = ''
132     install -Dm755 ${src}/alvr/xtask/resources/alvr.desktop $out/share/applications/alvr.desktop
133     install -Dm644 ${src}/resources/alvr.png $out/share/icons/hicolor/256x256/apps/alvr.png
135     # Install SteamVR driver
136     mkdir -p $out/{libexec,lib/alvr,share}
137     cp -r ./build/alvr_streamer_linux/lib64/. $out/lib
138     cp -r ./build/alvr_streamer_linux/libexec/. $out/libexec
139     cp -r ./build/alvr_streamer_linux/share/. $out/share
140     ln -s $out/lib $out/lib64
141   '';
143   passthru.updateScript = nix-update-script { };
145   meta = with lib; {
146     description = "Stream VR games from your PC to your headset via Wi-Fi";
147     homepage = "https://github.com/alvr-org/ALVR/";
148     changelog = "https://github.com/alvr-org/ALVR/releases/tag/v${version}";
149     license = licenses.mit;
150     mainProgram = "alvr_dashboard";
151     maintainers = with maintainers; [ passivelemon ];
152     platforms = platforms.linux;
153   };