From 8e67166c5897509d7718cd3d29d0819c45c09c6f Mon Sep 17 00:00:00 2001 From: GarandPLG Date: Thu, 16 Apr 2026 23:43:36 +0200 Subject: [PATCH] Make helpers public and improve Nix packaging MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Export `block_title` and `helpers` with `pub mod` for external use. Add Nix improvements: version check hook, update script, install check. Include post‑install step to copy soundtracks and rename binary. Extend meta with platforms, mainProgram, and maintainer handling. Update docs to show required imports for block title helpers. --- default.nix | 59 ++++++++++++++++++++++++---------- flake.nix | 4 +++ src/app/helpers/block_title.rs | 4 +++ src/app/helpers/mod.rs | 2 +- src/app/mod.rs | 2 +- 5 files changed, 52 insertions(+), 19 deletions(-) diff --git a/default.nix b/default.nix index 9002524..ad75c7a 100644 --- a/default.nix +++ b/default.nix @@ -1,25 +1,50 @@ { lib, rustPlatform, + # fetchFromGitea, pkg-config, alsa-lib, -}: -rustPlatform.buildRustPackage { - name = "war-in-tunnels"; - pname = "war-in-tunnels"; + versionCheckHook, + nix-update-script, +}: let version = "0.1.0"; +in + rustPlatform.buildRustPackage { + pname = "war-in-tunnels"; + inherit version; - src = ./.; - buildInputs = [alsa-lib]; - nativeBuildInputs = [pkg-config]; - cargoHash = lib.fakeHash; + src = ./.; + # src = fetchFromGitea { + # domain = "gitea.garandplg.com"; + # owner = "GarandPLG"; + # repo = "war-in-tunnels"; + # tag = "v${version}"; + # hash = lib.fakeHash; + # }; - meta = { - description = "TUI underground game"; - homepage = "https://gitea.garandplg.com/GarandPLG/war-in-tunnels"; - license = lib.licenses.mit; - maintainers = [ - "Garand_PLG" - ]; - }; -} + cargoHash = "sha256-Cv/sUzkiQuQS3ybg2glfXucIu+HtPi2brH/D7tqc3Mc="; + + nativeBuildInputs = [pkg-config]; + buildInputs = [alsa-lib]; + + nativeInstallCheckInputs = [versionCheckHook]; + doInstallCheck = true; + + passthru.updateScript = nix-update-script {}; + + postInstall = '' + cp -r soundtracks $out/bin + mv $out/bin/war_in_tunnels $out/bin/war-in-tunnels + ''; + + meta = { + description = "TUI underground game"; + homepage = "https://gitea.garandplg.com/GarandPLG/war-in-tunnels"; + license = lib.licenses.mit; + platforms = ["x86_64-linux"]; + maintainers = with lib.maintainers; [ + GarandPLG + ]; + mainProgram = "war-in-tunnels"; + }; + } diff --git a/flake.nix b/flake.nix index a1122fa..d65a4a3 100644 --- a/flake.nix +++ b/flake.nix @@ -44,6 +44,10 @@ src = ./.; buildInputs = with pkgs; [alsa-lib]; nativeBuildInputs = with pkgs; [pkg-config]; + postInstall = '' + cp -r soundtracks $out/bin + mv $out/bin/war_in_tunnels $out/bin/war-in-tunnels + ''; }; }; diff --git a/src/app/helpers/block_title.rs b/src/app/helpers/block_title.rs index 5bf484f..515e03d 100644 --- a/src/app/helpers/block_title.rs +++ b/src/app/helpers/block_title.rs @@ -31,7 +31,9 @@ use ratatui::{ /// # Example /// /// ```rust +/// use war_in_tunnels::app::helpers::block_title::block_title_helper; /// use ratatui::style::Color; +/// use ratatui::text::Line; /// /// let title: Line<'_> = block_title_helper( /// &[ @@ -89,7 +91,9 @@ pub fn block_title_helper<'a>(texts: &[(&'a str, Color)], separator: Option<&'a /// # Example /// /// ```rust +/// use war_in_tunnels::app::helpers::block_title::block_single_title_helper; /// use ratatui::style::Color; +/// use ratatui::text::Line; /// /// let title: Line<'_> = block_single_title_helper("Keybindings", Color::Magenta); /// // `title` now represents: [ Keybindings ] with “Keybindings” coloured magenta. diff --git a/src/app/helpers/mod.rs b/src/app/helpers/mod.rs index dc13391..1a0ee7f 100644 --- a/src/app/helpers/mod.rs +++ b/src/app/helpers/mod.rs @@ -1,4 +1,4 @@ -mod block_title; +pub mod block_title; mod cells_area; mod main_menu_option; mod zoom_level; diff --git a/src/app/mod.rs b/src/app/mod.rs index e757bff..14679f5 100644 --- a/src/app/mod.rs +++ b/src/app/mod.rs @@ -1,6 +1,6 @@ mod app; mod buildings; -mod helpers; +pub mod helpers; mod keybind; mod keybindings; mod state;