format rust and nix files

This commit is contained in:
Chance 2025-03-22 21:58:27 -04:00 committed by BitSyndicate
parent d694fa1eb9
commit a6fa240e5d
9 changed files with 214 additions and 186 deletions

3
.gitignore vendored
View file

@ -2,4 +2,5 @@
.idea
# Cargo.lock
*.log
.direnv
.direnv
**/result

120
Cargo.lock generated
View file

@ -103,6 +103,15 @@ version = "1.0.97"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dcfed56ad506cb2c684a14971b8861fdc3baaaae314b9e5f9bb532cbe3ba7a4f"
[[package]]
name = "approx"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f2a05fd1bd10b2527e20a2cd32d8873d115b8b39fe219ee25f42a8aca6ba278"
dependencies = [
"num-traits",
]
[[package]]
name = "arrayref"
version = "0.3.9"
@ -213,16 +222,6 @@ dependencies = [
"objc2",
]
[[package]]
name = "bstr"
version = "1.11.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "531a9155a481e2ee699d4f98f43c0ca4ff8ee1bfd55c31e9e98fb29d2b176fe0"
dependencies = [
"memchr",
"serde",
]
[[package]]
name = "bumpalo"
version = "3.17.0"
@ -310,6 +309,16 @@ version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724"
[[package]]
name = "cgmath"
version = "0.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a98d30140e3296250832bbaaff83b27dcd6fa3cc70fb6f1f3e5c9c0023b5317"
dependencies = [
"approx",
"num-traits",
]
[[package]]
name = "chrono"
version = "0.4.40"
@ -514,24 +523,12 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f25c0e292a7ca6d6498557ff1df68f32c99850012b6ea401cf8daf771f22ff53"
[[package]]
name = "either"
version = "1.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719"
[[package]]
name = "endian-type"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c34f04666d835ff5d62e058c3995147c06f42fe86ff053337632bca83e42702d"
[[package]]
name = "env_home"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c7f84e12ccf0a7ddc17a6c41c93326024c42920d7ee630d04950e6926645c0fe"
[[package]]
name = "equivalent"
version = "1.0.2"
@ -1154,25 +1151,6 @@ version = "0.4.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "30bde2b3dc3671ae49d8e2e9f044c7c005836e7a023ee57cffa25ab82764bb9e"
[[package]]
name = "lua-src"
version = "547.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1edaf29e3517b49b8b746701e5648ccb5785cde1c119062cbabbc5d5cd115e42"
dependencies = [
"cc",
]
[[package]]
name = "luajit-src"
version = "210.5.12+a4f56a4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b3a8e7962a5368d5f264d045a5a255e90f9aa3fc1941ae15a8d2940d42cac671"
dependencies = [
"cc",
"which",
]
[[package]]
name = "malloc_buf"
version = "0.0.6"
@ -1221,34 +1199,6 @@ dependencies = [
"adler2",
]
[[package]]
name = "mlua"
version = "0.10.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d3f763c1041eff92ffb5d7169968a327e1ed2ebfe425dac0ee5a35f29082534b"
dependencies = [
"anyhow",
"bstr",
"either",
"mlua-sys",
"num-traits",
"parking_lot",
"rustc-hash 2.1.1",
]
[[package]]
name = "mlua-sys"
version = "0.6.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1901c1a635a22fe9250ffcc4fcc937c16b47c2e9e71adba8784af8bca1f69594"
dependencies = [
"cc",
"cfg-if",
"lua-src",
"luajit-src",
"pkg-config",
]
[[package]]
name = "naga"
version = "24.0.0"
@ -1263,7 +1213,7 @@ dependencies = [
"hexf-parse",
"indexmap",
"log",
"rustc-hash 1.1.0",
"rustc-hash",
"spirv",
"strum",
"termcolor",
@ -1849,12 +1799,6 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
[[package]]
name = "rustc-hash"
version = "2.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d"
[[package]]
name = "rustix"
version = "0.38.44"
@ -2602,7 +2546,7 @@ dependencies = [
"parking_lot",
"profiling",
"raw-window-handle",
"rustc-hash 1.1.0",
"rustc-hash",
"smallvec",
"thiserror 2.0.12",
"wgpu-hal",
@ -2645,7 +2589,7 @@ dependencies = [
"range-alloc",
"raw-window-handle",
"renderdoc-sys",
"rustc-hash 1.1.0",
"rustc-hash",
"smallvec",
"thiserror 2.0.12",
"wasm-bindgen",
@ -2667,18 +2611,6 @@ dependencies = [
"web-sys",
]
[[package]]
name = "which"
version = "7.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2774c861e1f072b3aadc02f8ba886c26ad6321567ecc294c935434cad06f1283"
dependencies = [
"either",
"env_home",
"rustix 0.38.44",
"winsafe",
]
[[package]]
name = "winapi"
version = "0.3.9"
@ -3055,12 +2987,6 @@ dependencies = [
"memchr",
]
[[package]]
name = "winsafe"
version = "0.0.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d135d17ab770252ad95e9a872d365cf3090e3be864a34ab46f48555993efc904"
[[package]]
name = "write16"
version = "1.0.0"
@ -3176,6 +3102,7 @@ dependencies = [
"anyhow",
"backtrace",
"bytemuck",
"cgmath",
"chrono",
"colored 3.0.0",
"crashreport",
@ -3183,7 +3110,6 @@ dependencies = [
"futures",
"lazy_static",
"log",
"mlua",
"once_cell",
"parking_lot",
"regex",

View file

@ -1,30 +1,37 @@
{ lib, rustPlatform, nix-gitignore, bash, makeWrapper, dav1d, pkg-config }:
let
version = (builtins.fromTOML (builtins.readFile ./engine/Cargo.toml)).package.version;
src = nix-gitignore.gitignoreSource [] ./.;
in
rustPlatform.buildRustPackage rec {
pname = "zenyx";
inherit src version;
cargoLock.lockFile = ./Cargo.lock;
nativeBuildInputs = [
makeWrapper
pkg-config
];
buildInputs = [
bash
dav1d
];
doCheck = false;
{
lib,
rustPlatform,
nix-gitignore,
bash,
makeWrapper,
dav1d,
pkg-config,
}: let
version = (builtins.fromTOML (builtins.readFile ./engine/Cargo.toml)).package.version;
src = nix-gitignore.gitignoreSource [] ./.;
in
rustPlatform.buildRustPackage rec {
pname = "zenyx";
inherit src version;
cargoLock.lockFile = ./Cargo.lock;
nativeBuildInputs = [
makeWrapper
pkg-config
];
buildInputs = [
bash
dav1d
];
doCheck = false;
fixupPhase = ''
wrapProgram $out/bin/${pname} --set PATH ${bash}/bin:\$PATH
'';
fixupPhase = ''
wrapProgram $out/bin/${pname} --set PATH ${bash}/bin:\$PATH
'';
meta = {
description = "Test";
license = lib.licenses.mit;
platforms = lib.platforms.linux;
mainProgram = "zenyx";
};
}
meta = {
description = "Test";
license = lib.licenses.mit;
platforms = lib.platforms.linux;
mainProgram = "zenyx";
};
}

View file

@ -33,8 +33,6 @@ pub fn set_panic_hook() {
default_hook(info);
std::process::exit(0);
});
// Instead of using payload_as_str(), downcast the panic payload:
let payload = info.payload();
let payload_str = if let Some(s) = payload.downcast_ref::<&str>() {
*s
@ -65,7 +63,6 @@ https://github.com/Zenyx-Engine/Zenyx/issues
We take privacy seriously, and do not perform any automated error collection. In order to improve the software, we rely on people to submit reports.
Thank you kindly!", log_path.display());
println!("{}", panic_msg.red().bold());
println!("\nFor future reference, the error summary is as follows:\n{}", payload_str.red().bold());
std::process::exit(0);

View file

@ -33,7 +33,7 @@ impl Command for HelpCommand {
}
}
Ok(())
}
}
fn undo(&self) {}

View file

@ -1,8 +1,4 @@
use core::{
panic::set_panic_hook,
repl::setup,
splash, workspace,
};
use core::{panic::set_panic_hook, repl::setup, splash, workspace};
use colored::Colorize;
use log::info;
@ -22,7 +18,10 @@ async fn main() -> anyhow::Result<()> {
info!("Type 'help' for a list of commands.");
let repl_thread = std::thread::spawn(|| {
let rt = runtime::Builder::new_current_thread().enable_all().build().unwrap();
let rt = runtime::Builder::new_current_thread()
.enable_all()
.build()
.unwrap();
rt.block_on(core::repl::input::handle_repl())
});

79
flake.lock generated
View file

@ -1,5 +1,50 @@
{
"nodes": {
"alejandra": {
"inputs": {
"fenix": "fenix",
"flakeCompat": "flakeCompat",
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1730688725,
"narHash": "sha256-g0SSfTWZ5mtMOpQic+eqq9sXMy1E/7yKxxfupZd9V4A=",
"owner": "kamadorueda",
"repo": "alejandra",
"rev": "2bb91e309ca99656addff5c74545acbf5813636d",
"type": "github"
},
"original": {
"owner": "kamadorueda",
"ref": "3.1.0",
"repo": "alejandra",
"type": "github"
}
},
"fenix": {
"inputs": {
"nixpkgs": [
"alejandra",
"nixpkgs"
],
"rust-analyzer-src": "rust-analyzer-src"
},
"locked": {
"lastModified": 1730615655,
"narHash": "sha256-2HBR3zLn57LXKNRtxBb+O+uDqHM4n0pz51rPayMl4cg=",
"owner": "nix-community",
"repo": "fenix",
"rev": "efeb50e2535b17ffd4a135e6e3e5fd60a525180c",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "fenix",
"type": "github"
}
},
"flake-compat": {
"locked": {
"lastModified": 1733328505,
@ -14,6 +59,22 @@
"url": "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz"
}
},
"flakeCompat": {
"flake": false,
"locked": {
"lastModified": 1696426674,
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1742422364,
@ -48,12 +109,30 @@
},
"root": {
"inputs": {
"alejandra": "alejandra",
"flake-compat": "flake-compat",
"nixpkgs": "nixpkgs",
"rust-overlay": "rust-overlay",
"utils": "utils"
}
},
"rust-analyzer-src": {
"flake": false,
"locked": {
"lastModified": 1730555913,
"narHash": "sha256-KNHZUlqsEibg3YtfUyOFQSofP8hp1HKoY+laoesBxRM=",
"owner": "rust-lang",
"repo": "rust-analyzer",
"rev": "f17a5bbfd0969ba2e63a74505a80e55ecb174ed9",
"type": "github"
},
"original": {
"owner": "rust-lang",
"ref": "nightly",
"repo": "rust-analyzer",
"type": "github"
}
},
"rust-overlay": {
"inputs": {
"nixpkgs": "nixpkgs_2"

103
flake.nix
View file

@ -1,50 +1,67 @@
{
description = "Zenyx - A WSYWIG game engine written in rust ";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
utils.url = "github:numtide/flake-utils";
description = "Zenyx - A WSYWIG game engine written in rust ";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
utils.url = "github:numtide/flake-utils";
rust-overlay.url = "github:oxalica/rust-overlay";
flake-compat.url = "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz";
};
alejandra.url = "github:kamadorueda/alejandra/3.1.0";
alejandra.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = { self, nixpkgs, utils,rust-overlay, ... }: {
overlays.default = final: prev: {
zenyx = final.callPackage ./build.nix {};
};
}
//
utils.lib.eachDefaultSystem (system:
let pkgs = import nixpkgs {
inherit system;
overlays = [self.overlays.default (import rust-overlay) ];
};
in {
packages = {
inherit (pkgs) zenyx;
default = pkgs.zenyx;
};
devShells.default = pkgs.mkShell {
name = "zenyx";
nativeBuildInputs = with pkgs; [
(rust-bin.selectLatestNightlyWith (toolchain: toolchain.default.override {
extensions = [ "cargo" "clippy" ];
# targets = [ "arm-unknown-linux-gnueabihf" ];
}))
pkg-config
];
outputs = {
self,
nixpkgs,
utils,
rust-overlay,
alejandra,
...
}:
{
overlays.default = final: prev: {
zenyx = final.callPackage ./build.nix {};
};
}
// utils.lib.eachDefaultSystem (
system: let
pkgs = import nixpkgs {
inherit system;
overlays = [
self.overlays.default
(import rust-overlay)
];
};
buildInputs = with pkgs; [
vulkan-loader
wayland
libxkbcommon
xorg.libXcursor
xorg.libXrandr
xorg.libXi
xorg.libX11
xorg.libxcb
pkg-config
vulkan-loader
wayland
libxkbcommon
xorg.libXcursor
xorg.libXrandr
xorg.libXi
xorg.libX11
xorg.libxcb
pkg-config
];
};
}
);
in {
packages = {
inherit (pkgs) zenyx;
default = pkgs.zenyx;
};
devShells.default = pkgs.mkShell {
name = "zenyx";
nativeBuildInputs = with pkgs; [
rust-bin.stable.latest.default
pkg-config
];
buildInputs = buildInputs;
shellHook = ''
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${builtins.toString (pkgs.lib.makeLibraryPath buildInputs)}";
echo "Rust version: $(rustc --version)";
'';
};
formatter = alejandra.packages.${system}.default;
}
);
}

View file

@ -1,13 +1,15 @@
(import
(
import
(
let
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
nodeName = lock.nodes.root.inputs.flake-compat;
in
fetchTarball {
url = lock.nodes.${nodeName}.locked.url or "https://github.com/edolstra/flake-compat/archive/${lock.nodes.${nodeName}.locked.rev}.tar.gz";
sha256 = lock.nodes.${nodeName}.locked.narHash;
}
fetchTarball {
url = lock.nodes.${nodeName}.locked.url or "https://github.com/edolstra/flake-compat/archive/${lock.nodes.${nodeName}.locked.rev}.tar.gz";
sha256 = lock.nodes.${nodeName}.locked.narHash;
}
)
{ src = ./.; }
).shellNix
{src = ./.;}
)
.shellNix