62 lines
1.9 KiB
Nix
62 lines
1.9 KiB
Nix
{
|
|
inputs = {
|
|
flake-utils.url = "github:numtide/flake-utils";
|
|
naersk.url = "github:nix-community/naersk";
|
|
rust-overlay.url = "github:oxalica/rust-overlay";
|
|
nixpkgs.url = "github:NixOS/nixpkgs";
|
|
};
|
|
|
|
outputs = { self, flake-utils, naersk, nixpkgs, rust-overlay }:
|
|
flake-utils.lib.eachDefaultSystem (system:
|
|
let
|
|
overlays = [ (import rust-overlay) ];
|
|
pkgs = (import nixpkgs) { inherit system overlays; };
|
|
naersk' = pkgs.callPackage naersk { };
|
|
buildInputs = with pkgs; [
|
|
vulkan-loader
|
|
xorg.libXcursor
|
|
xorg.libXi
|
|
xorg.libXrandr
|
|
alsa-lib
|
|
udev
|
|
pkg-config
|
|
];
|
|
nativeBuildInputs = with pkgs; [
|
|
libxkbcommon
|
|
(rust-bin.selectLatestNightlyWith (toolchain:
|
|
toolchain.default.override {
|
|
extensions = [ "rust-src" "clippy" "rust-analyzer"];
|
|
}))
|
|
];
|
|
all_deps = with pkgs;
|
|
[ cargo-flamegraph cargo-expand nixpkgs-fmt cmake ] ++ buildInputs
|
|
++ nativeBuildInputs;
|
|
in rec {
|
|
# For `nix build` & `nix run`:
|
|
defaultPackage = packages.bevy_template;
|
|
packages = rec {
|
|
bevy_template = naersk'.buildPackage {
|
|
src = ./.;
|
|
nativeBuildInputs = nativeBuildInputs;
|
|
buildInputs = buildInputs;
|
|
postInstall = ''
|
|
cp -r assets $out/bin/
|
|
'';
|
|
# Disables dynamic linking when building with Nix
|
|
cargoBuildOptions = x: x ++ [ "--no-default-features" ];
|
|
};
|
|
};
|
|
|
|
# For `nix develop`:
|
|
devShell = pkgs.mkShell {
|
|
inputsFrom = [ packages.bevy_template ];
|
|
nativeBuildInputs = all_deps;
|
|
shellHook = ''
|
|
export CARGO_MANIFEST_DIR=$(pwd)
|
|
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${
|
|
pkgs.lib.makeLibraryPath all_deps
|
|
}"
|
|
'';
|
|
};
|
|
});
|
|
}
|