Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

alvr: build from source #308097

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

alvr: build from source #308097

wants to merge 1 commit into from

Conversation

jopejoe1
Copy link
Member

@jopejoe1 jopejoe1 commented Apr 30, 2024

Description of changes

This builds, but no idea if this actually works, would be cool if you could test this @PassiveLemon.

Closes #305232
Closes #334314

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.05 Release Notes (or backporting 23.05 and 23.11 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@PassiveLemon
Copy link
Contributor

Sure, I'll try to get to this soon

@ofborg ofborg bot added 8.has: package (new) This PR adds a new package 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10 10.rebuild-linux: 1 labels Apr 30, 2024
@PassiveLemon
Copy link
Contributor

Appears to build fine but upon running alvr_dashboard, it fails:

[18:14:41.026283555 INFO alvr_server_io] Session extrapolated successfully. Old session.json is stored as session_old.json
thread 'main' panicked at alvr/dashboard/src/main.rs:114:6:
called `Result::unwrap()` on an `Err` value: WinitEventLoop(NotSupported(NotSupportedError))
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

@NovaViper
Copy link
Contributor

NovaViper commented May 10, 2024

I'm trying to test this out myself in my flake but Im this error when I try to build it:

I just copied the contents of the pr and added it into my flake's custom pkgs folder, will update when it finishes compiling

@NovaViper
Copy link
Contributor

Hey @PassiveLemon I'm not sure how ideal this is but maybe as a temporary solution til a solution is found for the source package not working properly; we could target the ALVR nixpkg to the nightly builds? Those still have appimage release files

@PassiveLemon
Copy link
Contributor

I wouldn't necessarily mind that but I'd have to see what other maintainers say. Sometimes they can be picky about unstable packages.

In the long run, building from source is definitely the best way and it's where I personally would like to go

@NovaViper
Copy link
Contributor

NovaViper commented May 10, 2024

In the long run, building from source is definitely the best way and it's where I personally would like to go

Yeah definitely!

I just copied the contents of the pr and added it into my flake's custom pkgs folder, will update when it finishes compiling

Also quick update, running a backtrace for the app results in the log below.. something to do with Wayland apparently? (which I do have installed, as I'm using Plasma 6 with my desktop which supports a Nvidia RTX 2060 using the propritery drivers)

❯ RUST_BACKTRACE=full alvr_dashboard
thread 'main' panicked at alvr/dashboard/src/main.rs:114:6:
called `Result::unwrap()` on an `Err` value: WinitEventLoop(Os(OsError { line: 80, file: "/build/cargo-vendor-dir/winit-0.29.15/src/platform_impl/linux/wayland/event_loop/mod.rs", error: WaylandError(Connection(NoWaylandLib)) }))
stack backtrace:
   0:     0x55e013e9fae7 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h83d3e31f1809523c
   1:     0x55e013ed9f90 - core::fmt::write::h76573a5842288faa
   2:     0x55e013ebb245 - std::io::Write::write_fmt::hb095d534967ab243
   3:     0x55e013e9f8b4 - std::sys_common::backtrace::print::h73765b495122298a
   4:     0x55e013ea0427 - std::panicking::default_hook::{{closure}}::hfad133b7877f7d1a
   5:     0x55e013ea0187 - std::panicking::default_hook::hb7ccbed45ddd154f
   6:     0x55e013ea0998 - std::panicking::rust_panic_with_hook::h03308f3977d70e82
   7:     0x55e013ea087a - std::panicking::begin_panic_handler::{{closure}}::h6543c8dd74f459e9
   8:     0x55e013e9fd16 - std::sys_common::backtrace::__rust_end_short_backtrace::h68617e661e847078
   9:     0x55e013ea05c4 - rust_begin_unwind
  10:     0x55e012e65d45 - core::panicking::panic_fmt::hf7f647d933c4266a
  11:     0x55e012e66273 - core::result::unwrap_failed::hea2b65c1fd5e91f1
  12:     0x55e0130bce2f - alvr_dashboard::main::h72be6c550f519456
  13:     0x55e01300a693 - std::sys_common::backtrace::__rust_begin_short_backtrace::h547364518e5dba4a
  14:     0x55e013085bc9 - std::rt::lang_start::{{closure}}::hdefceb12001d1d82
  15:     0x55e013ea04c4 - std::panicking::try::hbc3e77d512204ae2
  16:     0x55e013e8d22b - std::rt::lang_start_internal::hf04efd76000e5213
  17:     0x55e0130bd1dc - main
  18:     0x7f853e96410e - __libc_start_call_main
  19:     0x7f853e9641c9 - __libc_start_main@@GLIBC_2.34
  20:     0x55e012e66685 - _start
  21:                0x0 - <unknown>

@PassiveLemon
Copy link
Contributor

PassiveLemon commented May 10, 2024

I do not use Wayland but I can report this to the ALVR Discord server and Github repo, unless you already have/are going to

@NovaViper
Copy link
Contributor

@PassiveLemon you go ahead, I'm actually trying to troubleshoot an entirely new issue with ALVR, can't get the audio working at all >_<

Also I DMed you a particular issue I saw on the ALVR Discord relating to someone's deviation of the latest ALVR release tars, that may help along updating the nixpkg too

@queezle42
Copy link
Contributor

WaylandError(Connection(NoWaylandLib))

That error is winit trying to dlopen the wayland library, which is a packaging problem and not an upstream bug.

Relevant winit documentation:
https://rust-windowing.github.io/winit/winit/platform/wayland/index.html

Here is a winit issue describing the same problem on NixOS: rust-windowing/winit#3244

@jopejoe1
Copy link
Member Author

Fixed the Wayland error, but still not running need to look into it:

[19:44:33.373619016 ERROR eframe::native::run] Exiting because of error: Found no glutin configs matching the template: ConfigTemplate { color_buffer_type: Rgb { r_size: 8, g_size: 8, b_size: 8 }, alpha_size: 8, depth_size: 0, stencil_size: 0, num_samples: None, min_swap_interval: None, max_swap_interval: None, config_surface_types: ConfigSurfaceTypes(WINDOW), api: None, transparency: false, single_buffering: false, stereoscopy: None, float_pixels: false, max_pbuffer_width: None, hardware_accelerated: None, max_pbuffer_height: None, native_window: None }. Error: Error { raw_code: None, raw_os_message: None, kind: NotFound } during event Resumed
thread 'main' panicked at alvr/dashboard/src/main.rs:114:6:
called `Result::unwrap()` on an `Err` value: NoGlutinConfigs(ConfigTemplate { color_buffer_type: Rgb { r_size: 8, g_size: 8, b_size: 8 }, alpha_size: 8, depth_size: 0, stencil_size: 0, num_samples: None, min_swap_interval: None, max_swap_interval: None, config_surface_types: ConfigSurfaceTypes(WINDOW), api: None, transparency: false, single_buffering: false, stereoscopy: None, float_pixels: false, max_pbuffer_width: None, hardware_accelerated: None, max_pbuffer_height: None, native_window: None }, Error { raw_code: None, raw_os_message: None, kind: NotFound })
stack backtrace:
   0:     0x55a2fbef4b37 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h83d3e31f1809523c
   1:     0x55a2fbf2efe0 - core::fmt::write::h76573a5842288faa
   2:     0x55a2fbf10295 - std::io::Write::write_fmt::hb095d534967ab243
   3:     0x55a2fbef4904 - std::sys_common::backtrace::print::h73765b495122298a
   4:     0x55a2fbef5477 - std::panicking::default_hook::{{closure}}::hfad133b7877f7d1a
   5:     0x55a2fbef51d7 - std::panicking::default_hook::hb7ccbed45ddd154f
   6:     0x55a2fbef59e8 - std::panicking::rust_panic_with_hook::h03308f3977d70e82
   7:     0x55a2fbef58ca - std::panicking::begin_panic_handler::{{closure}}::h6543c8dd74f459e9
   8:     0x55a2fbef4d66 - std::sys_common::backtrace::__rust_end_short_backtrace::h68617e661e847078
   9:     0x55a2fbef5614 - rust_begin_unwind
  10:     0x55a2faebad45 - core::panicking::panic_fmt::hf7f647d933c4266a
  11:     0x55a2faebb273 - core::result::unwrap_failed::hea2b65c1fd5e91f1
  12:     0x55a2fb111e1f - alvr_dashboard::main::hfca61549dae5a1e2
  13:     0x55a2fb05fc03 - std::sys_common::backtrace::__rust_begin_short_backtrace::h8bc8c32c609a56b2
  14:     0x55a2fb0dabc9 - std::rt::lang_start::{{closure}}::h1fdf975ca851bdda
  15:     0x55a2fbef5514 - std::panicking::try::hbc3e77d512204ae2
  16:     0x55a2fbee227b - std::rt::lang_start_internal::hf04efd76000e5213
  17:     0x55a2fb1121cc - main
  18:     0x7f49f3be410e - __libc_start_call_main
  19:     0x7f49f3be41c9 - __libc_start_main@@GLIBC_2.34
  20:     0x55a2faebb685 - _start
  21:                0x0 - <unknown>

@PassiveLemon
Copy link
Contributor

PassiveLemon commented Jun 9, 2024

In the next few days I will attempt to build off of this. Have you tried using the alvr_streamer_linux.tar.gz archive in the releases? Packaging may be easier with it

@NovaViper
Copy link
Contributor

@PassiveLemon Hey I was testing @mihranmashhud's derivation of the latest ALVR a few weeks back and it actually was working for me at the time! I came across it over in the ALVR discord. They used the alvr_streamer_linux.tar.gz file that ALVR now packages for Linux too!

{
  stdenv,
  lib,
  fetchurl,
  autoPatchelfHook,
  libva,
  alsa-lib,
  vulkan-loader,
  libvdpau,
  libunwind,
  wayland,
  libGL,
  libxkbcommon, openssl, x264, libdrm, ffmpeg, brotli, xvidcore,
}: let
  desktopEntry = ./alvr.desktop;
  icons = ./icons;
in
  stdenv.mkDerivation rec {
    pname = "alvr-latest";
    version = "20.8.0";

    src = fetchurl {
      url = "https://github.com/alvr-org/ALVR/releases/download/v${version}/alvr_streamer_linux.tar.gz";
      hash = "sha256-qEbHFmh0iDv+Pc/w+NF8gehHw47QZ71xjnBl2j8zFiE=";
    };

    nativeBuildInputs = [
      autoPatchelfHook
    ];

    buildInputs = [
      alsa-lib
      libunwind
      libva
      libvdpau
      stdenv.cc.cc
      vulkan-loader
    ];

    runtimeDependencies = [
      openssl
      wayland
      libxkbcommon
      libGL
      x264
      libdrm
      ffmpeg
      brotli
    ];

    sourceRoot = ".";

    installPhase = "
    runHook preInstall

    mkdir $out
    cp -r alvr_streamer_linux/* $out
    install -Dm444 ${desktopEntry} -t $out/share/applications
    cp -r ${icons} $out/share

    runHook postInstall
  ";
  }

@PassiveLemon
Copy link
Contributor

Oh nice, I was currently just working on a derivation using the archive and it works. I still have problems with that WinitEventLoop error though

@PassiveLemon
Copy link
Contributor

PassiveLemon commented Jun 10, 2024

Seems I have fixed it. Heres my derivation:

{ lib
, stdenv
, fetchzip
, fetchFromGitHub
, alsa-lib
, autoPatchelfHook
, brotli
, ffmpeg
, libdrm
, libGL
, libunwind
, libva
, libvdpau
, libxkbcommon
, nix-update-script
, openssl
, pipewire
, pulseaudio
, vulkan-loader
, wayland
, x264
, xorg
, xvidcore
}:
stdenv.mkDerivation (finalAttrs: {
  pname = "alvr";
  version = "20.8.1";

  src = fetchzip {
    url = "https://github.com/alvr-org/ALVR/releases/download/v${finalAttrs.version}/alvr_streamer_linux.tar.gz";
    hash = "sha256-8bQpEnzK4ZGE5P49Gh/fmxgyCBFTzD511q6aZxe0B/Y=";
  };

  alvrSrc = fetchFromGitHub {
    owner = "alvr-org";
    repo = "ALVR";
    rev = "v${finalAttrs.version}";
    hash = "sha256-znIRSax4thuBIpxW8BNqJSUYgIeY8g06qA9P/i8awvQ=";
  };

  nativeBuildInputs = [
    autoPatchelfHook
  ];

  buildInputs = [
    alsa-lib
    libunwind
    libva
    libvdpau
    vulkan-loader
  ];

  runtimeDependencies = [
    brotli
    ffmpeg
    libdrm
    libGL
    libxkbcommon
    openssl
    pipewire
    pulseaudio
    wayland
    x264
    xorg.libX11
    xorg.libXcursor
    xorg.libxcb
    xorg.libXi
  ];

  installPhase = ''
    runHook preInstall

    mkdir -p $out/share/applications
    cp -r $src/* $out
    install -Dm444 $alvrSrc/alvr/xtask/resources/alvr.desktop -t $out/share/applications
    install -Dm444 $alvrSrc/resources/alvr.png -t $out/share/icons/hicolor/256x256/apps

    runHook postInstall
  '';

  passthru.updateScript = nix-update-script { };

  meta = with lib; {
    description = "Stream VR games from your PC to your headset via Wi-Fi";
    homepage = "https://github.com/alvr-org/ALVR/";
    changelog = "https://github.com/alvr-org/ALVR/releases/tag/v${finalAttrs.version}";
    license = licenses.mit;
    maintainers = with maintainers; [ passivelemon ];
    platforms = platforms.linux;
    mainProgram = "alvr_dashboard";
  };
})

I haven't actually tested ALVR itself but it builds and runs. I'll give it a real test tomorrow.

@jopejoe1
Copy link
Member Author

In the next few days I will attempt to build off of this. Have you tried using the alvr_streamer_linux.tar.gz archive in the releases? Packaging may be easier with it

I have not, as that is a binary release and the goal of this pr was to build alvr from source, but that version could be used to update to a newer version, while a source build is still being worked on.

@PassiveLemon
Copy link
Contributor

Fixed the Wayland error, but still not running need to look into it

I can't seem to escape this issue either.

I have not, as that is a binary release and the goal of this pr was to build alvr from source, but that version could be used to update to a newer version, while a source build is still being worked on.

I still do plan on fulling building from source but as a stopgap measure, the archive should work nicely until we can figure out how to build from source. I found a Discourse from December about building ALVR from source and they hit the exact same issue

@PassiveLemon
Copy link
Contributor

PassiveLemon commented Jun 10, 2024

So I've given my derivation a test and here are the current problems:
Edit 2:
Upstream Issue alvr-org/ALVR#2160

@PassiveLemon
Copy link
Contributor

I cannot seem to get ALVR working at all. I don't think I will maintain it any longer as I do not use it anyways. Feel free to update the package with my derivation and remove me from maintainers. Maybe I'll come back in the future

@NovaViper
Copy link
Contributor

I'm going to try my hand at it, finally got my desktop up and running.

@NovaViper
Copy link
Contributor

NovaViper commented Jul 6, 2024

The draft derivation of ALVR works but I got that black screen issue, currently trying to figure out why that's happening but so far I don't see any of the Wayland issues on my end (I have a Nvidia RTX 2060 with the 555 drivers)

Edit: Got the black screen issue to go away! I had to do this fix on SteamVR; add ~/.local/share/Steam/steamapps/common/SteamVR/bin/vrmonitor.sh %command% to SteamVR's launch settings

@NovaViper
Copy link
Contributor

Got some good news! I can get ALVR fully working with little trouble (NVENC is still a bit buggy but using the H256 encoder works fine) along with the audio enabled and working fine too! One thing that I had to make sure existed is the active_runtime.json file for OpenXR; this at one point was giving me the biggest issues with SteaMVR.
The derivation looks good to me to merge!

My VR setup is a Oculus Quest 2 with Nvidia RTX 2060 v555 drivers with AMD 5600G CPU.

@justinas
Copy link
Member

justinas commented Aug 4, 2024

FYI 20.9.1 was recently released, including proper(-er?) Pipewire support.

I just tried out the Nixpkgs version (20.6.1) on my Quest 2 and after some workarounds such as the one mentioned in #308097 (comment) and manually wiring up the audio it seems to work okay. Would be awesome to get an up-to-date version in. I could lend a hand with testing the built-from-source derivation, but my setup is very similar to NovaViper's (Quest 2, NVIDIA dGPU).

@jopejoe1
Copy link
Member Author

jopejoe1 commented Aug 4, 2024

Will do another push in a few hours if I get the updated version to compile.

LuNeder added a commit to LuNeder/nixos-config that referenced this pull request Oct 27, 2024
ugh, at this point I just give up. I'll try doing this a different method or something, why tf do some commits have two parents I hate git

NixOS/nixpkgs#308097
alvr-org/ALVR#2476
ValveSoftware/SteamVR-for-Linux#748
NixOS/nixpkgs#341219
LuNeder added a commit to LuNeder/nixos-config that referenced this pull request Oct 27, 2024
@DaRacci
Copy link
Contributor

DaRacci commented Oct 27, 2024

I'm in the same boat, not having used my VR in a few weeks, I will test this out tonight.
Build wise I've built new generations a fair amount recently but may have removed the older generations already, will have a look though.

@DaRacci
Copy link
Contributor

DaRacci commented Oct 28, 2024

@LuNeder
ALVR is working for me, using my nix-config built on 2024-10-24

@eyJhb
Copy link
Member

eyJhb commented Oct 28, 2024

@LuNeder ALVR is working for me, using my nix-config built on 2024-10-24

Can you provide a revision of nixpkgs? Also, when you say ALVR is working, do you mean ALVR + SteamVR -> you can actually use it, show you library, fire up a game, etc.?

@DaRacci
Copy link
Contributor

DaRacci commented Oct 28, 2024

@LuNeder ALVR is working for me, using my nix-config built on 2024-10-24

Can you provide a revision of nixpkgs? Also, when you say ALVR is working, do you mean ALVR + SteamVR -> you can actually use it, show you library, fire up a game, etc.?

NixPkgs rev was 4c2fcb0, This was working fully inside a game on steam; I've just updated my system and can confirm the same, ALVR + steam no longer works.

Only way to do this will be a bisect i think, since that puts the change between the 18th and 20th which should be a small enough sample to do without too much pain.

Visual Diff:
image

So i see a few things that it could be just by eye, NVIDIA driver update from 560 to 565 and Kernel from 6.11.4 to 6.11.5; I don't have any more time to debug this, but hopefully this helps someone.

Just checked against LuNeders diff, they didn't update kernel above 6.11.4 or NVIDIA past 560.

@eyJhb
Copy link
Member

eyJhb commented Oct 28, 2024

So there is a fix for SteamVR not working with the latest unstable here #351928 . But this is NOT related to this PR in any way, it is a different issue introduced in how fhs is handled (likely introduced here #341219 ). So we should go ahead and try to get this merged :)

@Titaniumtown
Copy link
Contributor

haha thanks for the info @eyJhb. I noticed this issue but just thought steamvr was being buggy (as usual) and I ended up switching to monado + wivrn

Atemu added a commit to Atemu/nixpkgs that referenced this pull request Oct 29, 2024
A bunch of issues were found with the decimated steam, particularly around the
use of the new `inlcudeClosures`. Adding gamemode or gamescope to steam's
`extraPackages` would break in odd ways for instance and those appear to be
common patterns.

NixOS#350598
NixOS#308097

We definitely want to use something like `includeClosures` in the future but
let's revert back to just listing all deps in order to not have a broken steam
for 24.11.

NixOS#351928 aims to fix the issues experienced
here but is a breaking change and a bit too close for comfort w.r.t. staging
cycles.

Game specific libraries are disabled by default now though because
pressure-vessel should be able to take care of those before 24.11
releases. (Though you never know with Valve-time...) The flag to restore the
game specific libraries is retained just in case.

This partially reverts a3ccb7f
@Atemu Atemu mentioned this pull request Oct 29, 2024
13 tasks
@wegank wegank added 12.approvals: 3+ This PR was reviewed and approved by three or more reputable people and removed 12.approvals: 2 This PR was reviewed and approved by two reputable people labels Oct 29, 2024
@eyJhb
Copy link
Member

eyJhb commented Oct 29, 2024

@h7x4 you initially merged alvr. Any change you can get this merged, or are there any further concerns that should be addressed? :)

@NovaViper
Copy link
Contributor

NovaViper commented Oct 29, 2024

😓 Apologizes for the lengthy delay in my tests! I've been doing a ton of code clean up on my repo; so I now I can properly give this a test.

This is where my system is at currently (hadn't updated my flake.lock since my last commit).

❯ nix-info -m
 - system: `"x86_64-linux"`
 - host os: `Linux 6.10.11-xanmod1, NixOS, 24.11 (Vicuna), 24.11.20241017.8bddc04`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.23.3`
 - nixpkgs: `/nix/store/vjm0qmc6vkwgqzzymvsh7vd0ljjkifw2-92wy1qjs49l4cjqkswjbkrb2vabfkczn-source`

Edit: completely forgot to include what version of Nvidia drivers I have:

NVIDIA-SMI 560.35.03
Driver Version: 560.35.03
CUDA Version: 12.6 `

And SteamVR crashes on me the moment the headset tries to connect to ALVR 😰

@LuNeder
Copy link

LuNeder commented Oct 29, 2024

So there is a fix for SteamVR not working with the latest unstable here #351928 . But this is NOT related to this PR in any way, it is a different issue introduced in how fhs is handled (likely introduced here #341219 ). So we should go ahead and try to get this merged :)

Using that does not fix ALVR/SteamVR here. Weird. Can you confirm it works for you on the PR's latest commits/force-push?

@eyJhb
Copy link
Member

eyJhb commented Oct 30, 2024

Please use the issue I've created here for further discussions on the topic of ALVR+SteamVR not working on latest. It's not the fault of this PR in any way :) #352304

@NovaViper
Copy link
Contributor

SteamVR's working for me again after the fhs environment fix to Steam but sadly Hardware acceleration is still broken 😭

@balintbarna
Copy link

Anything I can do here to help, for example with testing?

@LuNeder
Copy link

LuNeder commented Nov 13, 2024

Anything I can do here to help, for example with testing?

Right now we're just waiting for the Nix Overlords to merge this tbh

@jopejoe1
Copy link
Member Author

Will merge this after branch-of because this currently contains breaking changes regarding support of nvidia GPUs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
8.has: package (new) This PR adds a new package 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10 10.rebuild-linux: 1 12.approvals: 3+ This PR was reviewed and approved by three or more reputable people
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update request: ALVR 20.6.1 → 20.9.1 Update request: ALVR 20.6.1 -> 20.8.1