Skip to content

Commit e317058

Browse files
Docs/more nixos instructions (#2775)
# 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 😄
1 parent 18c08dd commit e317058

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

docs/linux_dependencies.md

+43
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,49 @@ And enter it by just running `nix-shell`.
9898

9999
You should be able compile bevy programms using `cargo` within this nix-shell.
100100

101+
### Fast compilation
102+
103+
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.
104+
105+
Working off the above files, let's make the necessary changes.
106+
107+
For `.cargo/config.toml`, change the path to the linker from `/usr/bin/clang` to `clang`:
108+
109+
``` diff
110+
[target.x86_64-unknown-linux-gnu]
111+
- linker = "/usr/bin/clang"
112+
+ linker = "clang"
113+
rustflags = ["-Clink-arg=-fuse-ld=lld", "-Zshare-generics=y"]
114+
```
115+
116+
In `shell.nix`, add `lld` and `clang`:
117+
118+
``` diff
119+
buildInputs = [
120+
cargo
121+
pkgconfig udev alsaLib lutris
122+
x11 xorg.libXcursor xorg.libXrandr xorg.libXi
123+
vulkan-tools vulkan-headers vulkan-loader vulkan-validation-layers
124+
+ clang lld
125+
];
126+
```
127+
128+
### Building apps and using the GPU
129+
130+
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`:
131+
132+
``` diff
133+
{ pkgs ? import <nixpkgs> { } }:
134+
with pkgs;
135+
mkShell {
136+
+ shellHook = ''export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${pkgs.lib.makeLibraryPath [
137+
+ pkgs.alsaLib
138+
+ pkgs.udev
139+
+ pkgs.vulkan-loader
140+
+ ]}"'';
141+
buildInputs = [
142+
```
143+
101144
## Opensuse Tumbleweed
102145

103146
```bash

0 commit comments

Comments
 (0)