From 31367108f73469bcb7d84452f7191c353a08805d Mon Sep 17 00:00:00 2001 From: to-bak Date: Sun, 29 Dec 2024 20:20:51 +0100 Subject: [PATCH] Update linux dependency documentation for NixOS (and nix) (#16881) # Objective - Updates the linux-dependencies docs to 1) fix problems with nix `alsa-lib`, and 2) include additional documentation to run bevy with nix on non NixOS systems. (nix is a package manager that can be run outside of NixOS). ## Solution 1. the nix `alsa-lib` package doesn't include `alsa-plugins`, which bevy depends on. Instead, use the `alsa-lib-with-plugins` package, which wraps `alsa-plugins` into `alsa-lib`. For more information see: https://github.com/NixOS/nixpkgs/pull/277180 2. using nix on non NixOS systems, software like `nixGL` is required to correctly link graphics drivers. ## Testing - Tested on ubuntu 22.04 with nix. --- docs/linux_dependencies.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/docs/linux_dependencies.md b/docs/linux_dependencies.md index 521a198157..cc77ae8eb9 100644 --- a/docs/linux_dependencies.md +++ b/docs/linux_dependencies.md @@ -122,7 +122,7 @@ mkShell rec { pkg-config ]; buildInputs = [ - udev alsa-lib vulkan-loader + udev alsa-lib-with-plugins vulkan-loader xorg.libX11 xorg.libXcursor xorg.libXi xorg.libXrandr # To use the x11 feature libxkbcommon wayland # To use the wayland feature ]; @@ -134,6 +134,14 @@ And enter it by just running `nix-shell`. You should be able compile Bevy programs using `cargo run` within this nix-shell. You can do this in one line with `nix-shell --run "cargo run"`. +If running nix on a non NixOS system (such as ubuntu, arch etc.), [NixGL](https://github.com/nix-community/nixGL) is additionally required, +to link graphics drivers into the context of software installed by nix: + +1. Install an system specific nixGL wrapper ([docs](https://github.com/nix-community/nixGL)). + * If you're running a nvidia GPU choose `nixVulkanNvidia`. + * Otherwise, choose another wrapper appropriate for your system. +2. Run `nixVulkanNvidia-xxx.xxx.xx cargo run` to compile a bevy program, where `xxx-xxx-xx` denotes the graphics driver version `nixVulkanNvidia` was compiled with. + This is also possible with [Nix flakes](https://nixos.org/manual/nix/unstable/command-ref/new-cli/nix3-flake.html). Instead of creating `shell.nix`, you just need to add the derivation (`mkShell`) to your `devShells` in `flake.nix`. Run `nix develop` to enter the shell and