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

[Merged by Bors] - improve nix docs #7044

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 24 additions & 9 deletions docs/linux_dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,29 +101,44 @@ Depending on your graphics card, you may have to install one of the following:
sudo xbps-install -S pkgconf alsa-lib-devel libX11-devel eudev-libudev-devel
```

## NixOS
## [Nix](https://nixos.org)

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

```nix
{ pkgs ? import <nixpkgs> {} }:
with pkgs; mkShell rec {
{ pkgs ? import <nixpkgs> { } }:

with pkgs;

mkShell rec {
nativeBuildInputs = [
pkg-config
llvmPackages.bintools # To use lld linker
];
buildInputs = [
udev alsa-lib vulkan-loader
xlibsWrapper xorg.libXcursor xorg.libXrandr xorg.libXi # To use x11 feature
libxkbcommon wayland # To use wayland feature
xorg.libX11 xorg.libXcursor xorg.libXi xorg.libXrandr # To use the x11 feature
libxkbcommon wayland # To use the wayland feature
];
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath buildInputs;
LD_LIBRARY_PATH = lib.makeLibraryPath buildInputs;
}
```

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"`.
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"`.

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
`nix develop -c cargo run` to run the program. See
[Nix's documentation](https://nixos.org/manual/nix/unstable/command-ref/new-cli/nix3-develop.html)
for more information about `devShells`.

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` and `rustc` to `nativeBuildInputs`.

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`.
[Here](https://github.com/NixOS/nixpkgs/blob/master/pkgs/games/jumpy/default.nix)
is an example of packaging a Bevy program in nix.

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

Expand Down