dev: nix environment

This commit is contained in:
2026-09-03 20:12:49 +00:00
parent e6c9e65417
commit f063db3568
7 changed files with 1356 additions and 45 deletions
+47
View File
@@ -0,0 +1,47 @@
{ inputs, flake, self, pkgs }:
let
rustToolchain = pkgs.pkgsBuildHost.rust-bin.fromRustupToolchainFile ../rust-toolchain.toml;
runtimeLibraries = with pkgs; [
alsa-lib
vulkan-loader
udev
libx11
libxcursor
libxi
libxrandr
libxkbcommon
wayland
];
in {
default = pkgs.mkShell {
buildInputs = with pkgs; [
rustToolchain
stdenv.cc
git
pkg-config
shellcheck
file
openssl
] ++ runtimeLibraries;
shellHook = ''
export RUST_SRC_PATH="${rustToolchain}/lib/rustlib/src/rust/library"
if [ -d /run/opengl-driver/lib ]; then
export LD_LIBRARY_PATH="/run/opengl-driver/lib''${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
fi
export LD_LIBRARY_PATH="${pkgs.lib.makeLibraryPath runtimeLibraries}''${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
if git_root=$(${pkgs.git}/bin/git rev-parse --show-toplevel 2>/dev/null); then
export LOCAL_DIR="$git_root"
else
export LOCAL_DIR="$PWD"
fi
printf '%s\n' "bevy_controls dev shell"
printf '%s\n' "Library: cargo check && cargo test"
printf '%s\n' "Example: cd crate/bevy_controls/example/basic && cargo run --features x11"
'';
};
}
Generated
+1236 -15
View File
File diff suppressed because it is too large Load Diff
+16 -26
View File
@@ -1,38 +1,28 @@
{
description = "Bevy controls library and examples";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
hearth = {
url = "git+https://gitea.hectic-lab.com/hinterland/hearth.git";
inputs.nixpkgs.follows = "nixpkgs";
};
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs = {
nixpkgs.follows = "nixpkgs";
flake-utils.follows = "flake-utils";
};
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, flake-utils, rust-overlay }:
flake-utils.lib.eachDefaultSystem
(system:
outputs = { self, hearth, ... }@inputs:
let
overlays = [ (import rust-overlay) ];
pkgs = import nixpkgs {
inherit system overlays;
};
rustToolchain = (pkgs.pkgsBuildHost.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml);
nativeBuildInputs = with pkgs; [ rustToolchain pkg-config ];
buildInputs = with pkgs; [
openssl
shellcheck
file
];
flake = builtins.warn "Using the `flake` variable may produce a large source closure." ./.;
lib = import ./lib { inherit inputs flake self; };
in
with pkgs;
{
devShells.default = mkShell {
inherit buildInputs nativeBuildInputs;
hearth.lib.forAllSystemsWithPkgs lib.composedOverlays ({ system, pkgs }: {
legacyPackages.${system} = pkgs;
packages.${system} = import ./package { inherit self inputs flake pkgs; };
devShells.${system} = import ./devshell { inherit self inputs flake pkgs; };
}) // {
inherit lib;
};
}
);
}
+10
View File
@@ -0,0 +1,10 @@
{ self, flake, inputs }:
let
overlays = with inputs; [
hearth.overlays.default
(import rust-overlay)
];
in {
nixpkgs-lib = inputs.nixpkgs.lib;
composedOverlays = overlays;
}
+38
View File
@@ -0,0 +1,38 @@
{ pkgs }:
let
rustToolchain = pkgs.pkgsBuildHost.rust-bin.fromRustupToolchainFile ../../rust-toolchain.toml;
rustPlatform = pkgs.makeRustPlatform {
rustc = rustToolchain;
cargo = rustToolchain;
};
in rustPlatform.buildRustPackage {
pname = "bevy-controls";
version = "0.1.0";
src = ../..;
cargoLock.lockFile = ../../Cargo.lock;
cargoBuildFlags = [ "--workspace" ];
cargoTestFlags = [ "--workspace" ];
nativeBuildInputs = with pkgs; [
pkg-config
];
buildInputs = with pkgs; [
openssl
alsa-lib
vulkan-loader
udev
libx11
libxcursor
libxi
libxrandr
libxkbcommon
wayland
];
installPhase = ''
mkdir -p "$out"
touch "$out/workspace-built"
'';
}
+5
View File
@@ -0,0 +1,5 @@
{ pkgs, ... }:
{
bevy-controls = import ./bevy-controls { inherit pkgs; };
default = import ./bevy-controls { inherit pkgs; };
}
+1 -1
View File
@@ -1,3 +1,3 @@
[toolchain]
channel = '1.79.0'
components = ["rustfmt", "clippy"]
components = ["rustfmt", "clippy", "rust-src"]