From e41eece4a8c92defb94ab13a3411e2df561e78fc Mon Sep 17 00:00:00 2001 From: ALEZ-DEV Date: Fri, 19 Dec 2025 00:52:35 +0100 Subject: [PATCH] some little fixes (and nixos fix specific) --- Cargo.lock | 7 ++++ babylonia-terminal-sdk/Cargo.toml | 1 + .../src/components/wine_component.rs | 1 + babylonia-terminal-sdk/src/game_manager.rs | 21 ++++++++--- babylonia-terminal-sdk/src/game_patcher.rs | 36 +++++++++---------- 5 files changed, 44 insertions(+), 22 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e563ef5..67254b7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -374,6 +374,7 @@ dependencies = [ "serde_json", "tar", "tokio", + "whatadistro", "wincompatlib", "xz2", ] @@ -3963,6 +3964,12 @@ version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "53a85b86a771b1c87058196170769dd264f66c0782acf1ae6cc51bfd64b39082" +[[package]] +name = "whatadistro" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c97ebad4f59809511083f2161587445631bff21bb78d9e046b9ca5b2d05d913" + [[package]] name = "winapi" version = "0.3.9" diff --git a/babylonia-terminal-sdk/Cargo.toml b/babylonia-terminal-sdk/Cargo.toml index 748843d..7aad850 100644 --- a/babylonia-terminal-sdk/Cargo.toml +++ b/babylonia-terminal-sdk/Cargo.toml @@ -27,6 +27,7 @@ serde = { version = "1.0.197", features = ["derive"] } serde_json = "1.0.115" tar = "0.4.40" tokio = { version = "1.37.0", features = ["fs"] } +whatadistro = "0.1.0" wincompatlib = { version = "0.7.5", features = [ "dxvk", "wine-bundles", diff --git a/babylonia-terminal-sdk/src/components/wine_component.rs b/babylonia-terminal-sdk/src/components/wine_component.rs index fc9ee8e..7dfe815 100644 --- a/babylonia-terminal-sdk/src/components/wine_component.rs +++ b/babylonia-terminal-sdk/src/components/wine_component.rs @@ -111,6 +111,7 @@ impl WineComponent { debug!("Wine binary path : {:?}", wine_bin_location); let mut wine = wincompatlib::prelude::Wine::from_binary(wine_bin_location); + wine.prefix = prefix.clone(); wine.init_prefix(Some(prefix)).unwrap(); diff --git a/babylonia-terminal-sdk/src/game_manager.rs b/babylonia-terminal-sdk/src/game_manager.rs index 87bb086..0d38f14 100644 --- a/babylonia-terminal-sdk/src/game_manager.rs +++ b/babylonia-terminal-sdk/src/game_manager.rs @@ -292,11 +292,21 @@ impl GameManager { let wine_path = GameConfig::get_config_directory() .await .join("wine") + .join("bin") .join("wine"); + let mut wine_path = wine_path.to_str().unwrap(); + + if let Some(distro) = whatadistro::identify() { + if distro.is_similar("nixos") { + wine_path = "wine"; + + info!("Nixos detected, using system Wine..."); + }; + }; //command.push(wine.python.to_str().unwrap()); - command.push(wine_path.to_str().unwrap()); - command.push("run"); + command.push(wine_path); + //command.push("run"); command.push(binary_path.to_str().unwrap()); let launch_option; @@ -324,11 +334,14 @@ impl GameManager { } debug!("Command preview -> {}", command.join(" ")); + debug!( + "Command envs -> {:?}", + wine.get_envs()["WINEPREFIX"].clone() + ); Ok(Command::new(command[0]) .args(&command[1..command.len()]) - .envs(wine.get_envs()) - .env("Wine_LOG", "1") + .env("WINE_PREFIX", wine.get_envs()["WINEPREFIX"].clone()) .stdin(Stdio::piped()) .stdout(Stdio::piped()) .stderr(Stdio::piped()) diff --git a/babylonia-terminal-sdk/src/game_patcher.rs b/babylonia-terminal-sdk/src/game_patcher.rs index 20e40c5..93a6748 100644 --- a/babylonia-terminal-sdk/src/game_patcher.rs +++ b/babylonia-terminal-sdk/src/game_patcher.rs @@ -58,29 +58,29 @@ pub async fn patch_game(game_dir: PathBuf) -> anyhow::Result<()> { // section to replace the executable with the patched one - let executable_path = game_dir - .join(get_game_name()) - .join(get_game_name_with_executable()); + //let executable_path = game_dir + // .join(get_game_name()) + // .join(get_game_name_with_executable()); - debug!("{:?}", executable_path); + //debug!("{:?}", executable_path); - if executable_path.exists() { - remove_file(executable_path.clone()).await?; - } + //if executable_path.exists() { + // remove_file(executable_path.clone()).await?; + //} - match PatchedGameExecutable::get_exectable() { - Some(exe) => { - let mut file = File::create(executable_path).await?; + //match PatchedGameExecutable::get_exectable() { + // Some(exe) => { + // let mut file = File::create(executable_path).await?; - let data: Result, _> = exe.data.bytes().collect(); - let data = data.expect("Unable to read executable data"); + // let data: Result, _> = exe.data.bytes().collect(); + // let data = data.expect("Unable to read executable data"); - file.write_all(&data).await?; - } - None => anyhow::bail!( - "Game executable not included in the binary! Please report this to the developer!" - ), - } + // file.write_all(&data).await?; + // } + // None => anyhow::bail!( + // "Game executable not included in the binary! Please report this to the developer!" + // ), + //} let mut config = GameConfig::get_config().await; config.is_game_patched = true;