You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

87 lines
2.5 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/nixpkgs-unstable";
wild.url = "github:davidlattimore/wild";
};
outputs = { self, flake-utils, naersk, nixpkgs, rust-overlay, wild }:
flake-utils.lib.eachDefaultSystem (system:
let
systems = ["x86_64-linux"];
overlays = [
(import rust-overlay)
wild.overlays.default
];
wildStdenv = pkgs.useWildLinker pkgs.stdenv;
pkgs = (import nixpkgs) {
inherit system overlays;
config.allowUnfree = true;
};
naersk' = pkgs.callPackage naersk { };
buildInputs = with pkgs; [
vulkan-loader
xorg.libXcursor
xorg.libXi
xorg.libXrandr
libxkbcommon
wayland
alsa-lib
udev
pkg-config
clang
lld
mold
binaryen
];
nativeBuildInputs = with pkgs; [
libxkbcommon
(rust-bin.selectLatestNightlyWith (toolchain: toolchain.default.override {
extensions = [ "rust-src" "clippy" "rustc-codegen-cranelift-preview" ];
targets = [ "x86_64-unknown-linux-gnu" "wasm32-unknown-unknown" ];
}))
];
all_deps = with pkgs; [
# cargo-expand
nixpkgs-fmt
cmake
wasm-pack
wasm-bindgen-cli
trunk
simple-http-server
zip
unzip
mdcat
rust-analyzer
] ++ buildInputs ++ nativeBuildInputs;
in
rec {
# For `nix build` & `nix run`:
defaultPackage = packages.bevy_template { stdenv = wildStdenv; };
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.override { stdenv = wildStdenv; } {
nativeBuildInputs = all_deps;
shellHook = ''
export CARGO_MANIFEST_DIR=$(pwd)
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${pkgs.lib.makeLibraryPath all_deps}"
'';
};
}
);
}