Nixerus/pkgs/apps/games/alvr/default.nix

70 lines
2.3 KiB
Nix

{ stdenv, fetchzip, fetchurl, lib, alsa-lib, gtk3, libunwind, x264, vulkan-loader, xorg, libva, libdrm, libvdpau, libbsd, libmd, xz }:
stdenv.mkDerivation rec {
pname = "alvr";
version = "v20.4.3";
src = fetchzip {
url = "https://github.com/alvr-org/ALVR/releases/download/${version}/alvr_streamer_linux.tar.gz";
name = "${pname}-${version}";
sha256 ="sha256-2gCy25FaEPe/eDddhUI8xKM1xrlthIk/yaCfbSLhlek=";
};
sourceRoot = ".";
rpath = lib.makeLibraryPath [
stdenv.cc.cc.lib
alsa-lib
gtk3
x264.lib
vulkan-loader
xorg.libX11
xorg.libXau
xorg.libXdmcp
xorg.libXext
xorg.libXfixes
libva
libdrm
libunwind
libbsd
libmd
xz
];
preferLocalBuild = true;
dontBuild = true;
installPhase = ''
runHook preInstall
mkdir -p $out/bin $out/opt/ALVR $out/share/vulkan/explicit_layer.d $out/share/applications/ $out/share/icons/hicolor/256x256/apps/
mv ${src.name}/* $out/opt/ALVR
cp ${./alvr.png} $out/share/icons/hicolor/256x256/apps/alvr.png
cp ${./alvr.desktop} $out/share/applications/alvr.desktop
ln -s $out/opt/ALVR/bin/alvr_dashboard $out/bin
ln -s $out/opt/ALVR/share/vulkan/explicit_layer.d/alvr_x86_64.json $out/share/vulkan/explicit_layer.d
runHook postInstall
'';
fixupPhase = ''
runHook preFixup
patchelf --set-rpath "${rpath}" --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" $out/opt/ALVR/bin/alvr_dashboard
patchelf --set-rpath "${rpath}" --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" $out/opt/ALVR/libexec/alvr/vrcompositor-wrapper
patchelf --set-rpath "${rpath}" $out/opt/ALVR/libexec/alvr/alvr_drm_lease_shim.so
patchelf --set-rpath "${rpath}" $out/opt/ALVR/lib64/libalvr_vulkan_layer.so
patchelf --set-rpath "${rpath}" $out/opt/ALVR/lib64/alvr/bin/linux64/driver_alvr_server.so
sed -i "s#../../../lib64/libalvr_vulkan_layer.so#$out/opt/ALVR/lib64/libalvr_vulkan_layer.so#" $out/opt/ALVR/share/vulkan/explicit_layer.d/alvr_x86_64.json
runHook postFixup
'';
meta = with lib; {
description = "ALVR - Stream VR games from your PC to your headset via Wi-Fi.";
homepage = "https://github.com/alvr-org/ALVR";
maintainers = with maintainers; [];
license = licenses.mit;
platforms = [ "x86_64-linux" ];
};
}