Skip to content

Commit d296326

Browse files
committed
improve nix docs (#7044)
# Objective `xlibsWrapper` is being deprecated: NixOS/nixpkgs#194054, this pr removes the deprecated xlibsWrapper and makes a couple more improvements ## Solution - rename NixOS to Nix since this is not specific to NixOS - remove usage of `xlibsWrapper` - add instructions for nix flakes with `nix develop` - add example of a packaged bevy program in nixpkgs - minor cosmetic/grammatical changes
1 parent 61e027e commit d296326

File tree

1 file changed

+24
-9
lines changed

1 file changed

+24
-9
lines changed

docs/linux_dependencies.md

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -101,29 +101,44 @@ Depending on your graphics card, you may have to install one of the following:
101101
sudo xbps-install -S pkgconf alsa-lib-devel libX11-devel eudev-libudev-devel
102102
```
103103

104-
## NixOS
104+
## [Nix](https://nixos.org)
105105

106106
Add a `shell.nix` file to the root of the project containing:
107107

108108
```nix
109-
{ pkgs ? import <nixpkgs> {} }:
110-
with pkgs; mkShell rec {
109+
{ pkgs ? import <nixpkgs> { } }:
110+
111+
with pkgs;
112+
113+
mkShell rec {
111114
nativeBuildInputs = [
112115
pkg-config
113-
llvmPackages.bintools # To use lld linker
114116
];
115117
buildInputs = [
116118
udev alsa-lib vulkan-loader
117-
xlibsWrapper xorg.libXcursor xorg.libXrandr xorg.libXi # To use x11 feature
118-
libxkbcommon wayland # To use wayland feature
119+
xorg.libX11 xorg.libXcursor xorg.libXi xorg.libXrandr # To use the x11 feature
120+
libxkbcommon wayland # To use the wayland feature
119121
];
120-
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath buildInputs;
122+
LD_LIBRARY_PATH = lib.makeLibraryPath buildInputs;
121123
}
122124
```
123125

124-
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"`.
126+
And enter it by just running `nix-shell`.
127+
You should be able compile Bevy programs using `cargo run` within this nix-shell.
128+
You can do this in one line with `nix-shell --run "cargo run"`.
129+
130+
This is also possible with [Nix flakes](https://nixos.org/manual/nix/unstable/command-ref/new-cli/nix3-flake.html).
131+
Instead of creating `shell.nix`, you just need to add the derivation (`mkShell`)
132+
to your `devShells` in `flake.nix`. Run `nix develop` to enter the shell and
133+
`nix develop -c cargo run` to run the program. See
134+
[Nix's documentation](https://nixos.org/manual/nix/unstable/command-ref/new-cli/nix3-develop.html)
135+
for more information about `devShells`.
136+
137+
Note that this template does not add Rust to the environment because there are many ways to do it.
138+
For example, to use stable Rust from nixpkgs, you can add `cargo` and `rustc` to `nativeBuildInputs`.
125139

126-
Note that this template does not add Rust to the environment because there are many ways to do it. For example, to use stable Rust from nixpkgs you can add `cargo` to `nativeBuildInputs`.
140+
[Here](https://github.com/NixOS/nixpkgs/blob/master/pkgs/games/jumpy/default.nix)
141+
is an example of packaging a Bevy program in nix.
127142

128143
## [OpenSUSE](https://www.opensuse.org/)
129144

0 commit comments

Comments
 (0)