From e3170586776b165f40e446780fc4f9a4ed04187d Mon Sep 17 00:00:00 2001 From: Thomas Heartman Date: Mon, 6 Sep 2021 19:16:09 +0000 Subject: [PATCH] Docs/more nixos instructions (#2775) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # Objective Expand the documentation for NixOS setups (as discussed in Discord) ## Solution Added more info to `linux_dependencies.md` about NixOS. This is based off my own experience (as documented in [this blog post](https://blog.thomasheartman.com/posts/bevy-getting-started-on-nixos)), so I can't confirm that it'll work for everyone. However, if there are further tweaks necessary, then I think that this should nevertheless work as a good starting point and should give future users an idea of what they may need to change or update. Feedback and tweaks are very welcome 😄 --- docs/linux_dependencies.md | 43 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/docs/linux_dependencies.md b/docs/linux_dependencies.md index 2c46fad42e..9c1b955d21 100644 --- a/docs/linux_dependencies.md +++ b/docs/linux_dependencies.md @@ -98,6 +98,49 @@ And enter it by just running `nix-shell`. You should be able compile bevy programms using `cargo` within this nix-shell. +### Fast compilation + +According to the Bevy getting started guide (for v0.5), you can enable fast compilation by add a Cargo config file and by adding `lld` and `clang`. As long as you add `clang` and `lld` to your environment, it should mostly work, but you'll still need to modify the Cargo config file so that it doesn't point to `/usr/bin/clang` anymore. + +Working off the above files, let's make the necessary changes. + +For `.cargo/config.toml`, change the path to the linker from `/usr/bin/clang` to `clang`: + +``` diff + [target.x86_64-unknown-linux-gnu] +- linker = "/usr/bin/clang" ++ linker = "clang" + rustflags = ["-Clink-arg=-fuse-ld=lld", "-Zshare-generics=y"] +``` + +In `shell.nix`, add `lld` and `clang`: + +``` diff + buildInputs = [ + cargo + pkgconfig udev alsaLib lutris + x11 xorg.libXcursor xorg.libXrandr xorg.libXi + vulkan-tools vulkan-headers vulkan-loader vulkan-validation-layers ++ clang lld + ]; +``` + +### Building apps and using the GPU + +If you run into issues with building basic apps or activating the GPU ('thread 'main' panicked at 'Unable to find a GPU!'), then you may need to update your environment's `LD_LIBRARY_PATH`. To solve issues relating to missing `libudev.so.1` files, `alsa` drivers, and being unable to find a GPU, try updating the environment variable in your `shell.nix` by creating a `shellHook`: + +``` diff + { pkgs ? import { } }: + with pkgs; + mkShell { ++ shellHook = ''export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${pkgs.lib.makeLibraryPath [ ++ pkgs.alsaLib ++ pkgs.udev ++ pkgs.vulkan-loader ++ ]}"''; + buildInputs = [ +``` + ## Opensuse Tumbleweed ```bash