Skip to content
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,9 @@ compressed_texture_cache

# Generated by "examples/dev_tools/schedule_data.rs"
**/app_data.ron

# Generated by direnv
.direnv

# Generated by Visual Studio Code
.vscode
73 changes: 7 additions & 66 deletions docs/linux_dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,73 +104,14 @@ sudo xbps-install -S pkgconf alsa-lib-devel libX11-devel eudev-libudev-devel

### flake.nix

Add a `flake.nix` file to the root of your GitHub repository containing:
There is a `flake.nix` file to the root of this repository. So you can just do

```nix
{
description = "bevy flake";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
rust-overlay.url = "github:oxalica/rust-overlay";
flake-utils.url = "github:numtide/flake-utils";
};

outputs =
{
nixpkgs,
rust-overlay,
flake-utils,
...
}:
flake-utils.lib.eachDefaultSystem (
system:
let
overlays = [ (import rust-overlay) ];
pkgs = import nixpkgs {
inherit system overlays;
};
in
{
devShells.default =
with pkgs;
mkShell {
buildInputs =
[
# Rust dependencies
(rust-bin.stable.latest.default.override { extensions = [ "rust-src" ]; })
pkg-config
]
++ lib.optionals (lib.strings.hasInfix "linux" system) [
# for Linux
# Audio (Linux only)
alsa-lib
# Cross Platform 3D Graphics API
vulkan-loader
# For debugging around vulkan
vulkan-tools
# Other dependencies
libudev-zero
libx11
libxcursor
libxi
libxrandr
libxkbcommon
wayland
];
RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
LD_LIBRARY_PATH = lib.makeLibraryPath [
vulkan-loader
libx11
libxi
libxcursor
libxkbcommon
wayland
];
};
}
);
}
```bash
nix develop
```
If you have `direnv` installed as well you just need to allow it for this repo.
```bash
direnv allow
```

> [!TIP]
Expand Down
96 changes: 96 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

85 changes: 85 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
{
description = "Bevy development environment flake";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
rust-overlay.url = "github:oxalica/rust-overlay";
flake-utils.url = "github:numtide/flake-utils";
};

outputs =
{
nixpkgs,
flake-utils,
rust-overlay,
...
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ (import rust-overlay) ];
};

bevyDeps =
with pkgs;
[
pkg-config
(rust-bin.stable.latest.default.override {
extensions = [
"rust-src"
"rust-analyzer"
];
})
]
++ lib.optionals stdenv.isLinux (
with pkgs;
[
# Systembundles & Linkers
lld
clang

# Audio
alsa-lib

# Graphics / Windowing
vulkan-loader
vulkan-tools
wayland
libx11
libxcursor
libxi
libxrandr
libxkbcommon

# Input / Hardware
libudev-zero
]
);

# Runtime libs for dlopen
runtimeLibs = with pkgs; [
vulkan-loader
alsa-lib
libx11
libxcursor
libxi
libxrandr
libxkbcommon
wayland
libudev-zero
];
in
{
devShells.default = pkgs.mkShell {
nativeBuildInputs = bevyDeps;

# Make Winit en Bevy find necessary libraries on Linux
LD_LIBRARY_PATH = pkgs.lib.optionalString pkgs.stdenv.isLinux (
pkgs.lib.makeLibraryPath runtimeLibs
);
};
}
);
}
Loading