Pre-cargo initial commit
commit
0c61d5d5d6
@ -0,0 +1,28 @@
|
|||||||
|
[unstable]
|
||||||
|
codegen-backend = true
|
||||||
|
|
||||||
|
[profile.dev]
|
||||||
|
codegen-backend = "cranelift"
|
||||||
|
|
||||||
|
[profile.dev.package."*"]
|
||||||
|
codegen-backend = "llvm"
|
||||||
|
|
||||||
|
[profile.release]
|
||||||
|
lto = true
|
||||||
|
opt-level = 'z'
|
||||||
|
|
||||||
|
# for Linux
|
||||||
|
[target.x86_64-unknown-linux-gnu]
|
||||||
|
linker = "clang"
|
||||||
|
rustflags = [
|
||||||
|
# (Nightly) Make the current crate share its generic instantiations
|
||||||
|
"-Zshare-generics=y",
|
||||||
|
# Link with Mold
|
||||||
|
"-C",
|
||||||
|
"link-arg=-fuse-ld=mold"
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
# for Windows
|
||||||
|
[target.x86_64-pc-windows-msvc]
|
||||||
|
linker = "rust-lld.exe"
|
||||||
@ -0,0 +1,19 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -e
|
||||||
|
if [[ ! -d "/home/pop/Projects/src/localhost/games" ]]; then
|
||||||
|
echo "Cannot find source directory; Did you move it?"
|
||||||
|
echo "(Looking for "/home/pop/Projects/src/localhost/games")"
|
||||||
|
echo 'Cannot force reload with this script - use "direnv reload" manually and then try again'
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# rebuild the cache forcefully
|
||||||
|
_nix_direnv_force_reload=1 direnv exec "/home/pop/Projects/src/localhost/games" true
|
||||||
|
|
||||||
|
# Update the mtime for .envrc.
|
||||||
|
# This will cause direnv to reload again - but without re-building.
|
||||||
|
touch "/home/pop/Projects/src/localhost/games/.envrc"
|
||||||
|
|
||||||
|
# Also update the timestamp of whatever profile_rc we have.
|
||||||
|
# This makes sure that we know we are up to date.
|
||||||
|
touch -r "/home/pop/Projects/src/localhost/games/.envrc" "/home/pop/Projects/src/localhost/games/.direnv"/*.rc
|
||||||
@ -0,0 +1,86 @@
|
|||||||
|
{
|
||||||
|
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}"
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue