From fcbb5f87ba82d7597a301253f7ca38e32774196c Mon Sep 17 00:00:00 2001 From: Leon Liu Date: Mon, 18 Aug 2025 03:12:11 +0000 Subject: [PATCH] update --- .gitignore | 3 ++- Cargo.toml | 4 ++-- flake.nix | 70 ++++++++++++++++++++++++++++++++++++------------------ win | 4 ++++ 4 files changed, 55 insertions(+), 26 deletions(-) create mode 100755 win diff --git a/.gitignore b/.gitignore index a46229b..ec68511 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /target/ /.claude/ -/.direnv/ \ No newline at end of file +/.direnv/ +/*.exe \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml index 275a64a..c4da94f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2024" [dependencies] -bevy = "0.16" +bevy = { version = "0.16", features = ["wayland"] } bevy-inspector-egui = "0.33.1" bevy_panorbit_camera = "0.28" big_space = { version = "0.10.0", features = ["camera"] } @@ -30,4 +30,4 @@ opt-level = 1 opt-level = 3 [features] -default = ["bevy/bevy_dev_tools", "bevy/dynamic_linking"] +dev = ["bevy/bevy_dev_tools", "bevy/dynamic_linking"] diff --git a/flake.nix b/flake.nix index 3688693..b0ce551 100644 --- a/flake.nix +++ b/flake.nix @@ -7,44 +7,68 @@ flake-utils.url = "github:numtide/flake-utils"; }; - outputs = { nixpkgs, rust-overlay, flake-utils, ... }: - flake-utils.lib.eachDefaultSystem (system: + outputs = + { + nixpkgs, + rust-overlay, + flake-utils, + ... + }: + flake-utils.lib.eachDefaultSystem ( + system: let overlays = [ (import rust-overlay) ]; pkgs = import nixpkgs { inherit system overlays; + crossSystem = { + config = "x86_64-w64-mingw32"; + }; + config.microsoftVisualStudioLicenseAccepted = true; + }; + # I don't understand why we need this instead of just using pkgs.pkgsBuildHost, + # but the wine64 from here works and the wine64 from pkgs.pkgsBuildHost doesn't. + pkgsLocal = import nixpkgs { + inherit system; + }; + rust-toolchain = pkgs.pkgsBuildHost.rust-bin.stable.latest.default.override { + extensions = [ + "rust-src" + "rust-analyzer" + ]; + targets = [ + "wasm32-unknown-unknown" + "x86_64-pc-windows-gnu" + ]; }; in with pkgs; { devShells.default = mkShell rec { nativeBuildInputs = [ - pkg-config - llvmPackages.bintools # To use lld linker + rust-toolchain + pkgsLocal.llvmPackages.bintools # To use lld linker + pkgsLocal.openssl + pkgsLocal.eza + pkgsLocal.fd + pkgsLocal.udev + pkgsLocal.alsa-lib-with-plugins + pkgsLocal.vulkan-loader + pkgsLocal.xorg.libX11 + pkgsLocal.xorg.libXcursor + pkgsLocal.xorg.libXi + pkgsLocal.xorg.libXrandr # To use the x11 feature + pkgsLocal.libxkbcommon + pkgsLocal.wayland # To use the wayland feature + pkgsLocal.clang + pkgsLocal.nil + pkgsLocal.nixfmt ]; buildInputs = [ - openssl - pkg-config - eza - fd - (rust-bin.selectLatestNightlyWith (toolchain: toolchain.default.override { - extensions = [ "rust-src" "rust-analyzer" ]; - targets = [ "wasm32-unknown-unknown" ]; - })) - udev - alsa-lib-with-plugins - vulkan-loader - xorg.libX11 - xorg.libXcursor - xorg.libXi - xorg.libXrandr # To use the x11 feature - libxkbcommon - wayland # To use the wayland feature - clang + pkgs.windows.pthreads ]; - LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath buildInputs; + LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath nativeBuildInputs; shellHook = '' alias ls=exa diff --git a/win b/win new file mode 100755 index 0000000..96c4ccb --- /dev/null +++ b/win @@ -0,0 +1,4 @@ +#!/bin/sh +cargo build --target x86_64-pc-windows-gnu && +cp target/x86_64-pc-windows-gnu/debug/solar-sim.exe . && +exec ./solar-sim.exe "$@" \ No newline at end of file