Make helpers public and improve Nix packaging

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.
This commit is contained in:
2026-04-16 23:43:36 +02:00
parent f5ef4b4931
commit 8e67166c58
5 changed files with 52 additions and 19 deletions
+34 -9
View File
@@ -1,25 +1,50 @@
{ {
lib, lib,
rustPlatform, rustPlatform,
# fetchFromGitea,
pkg-config, pkg-config,
alsa-lib, alsa-lib,
}: versionCheckHook,
rustPlatform.buildRustPackage { nix-update-script,
name = "war-in-tunnels"; }: let
pname = "war-in-tunnels";
version = "0.1.0"; version = "0.1.0";
in
rustPlatform.buildRustPackage {
pname = "war-in-tunnels";
inherit version;
src = ./.; src = ./.;
buildInputs = [alsa-lib]; # src = fetchFromGitea {
# domain = "gitea.garandplg.com";
# owner = "GarandPLG";
# repo = "war-in-tunnels";
# tag = "v${version}";
# hash = lib.fakeHash;
# };
cargoHash = "sha256-Cv/sUzkiQuQS3ybg2glfXucIu+HtPi2brH/D7tqc3Mc=";
nativeBuildInputs = [pkg-config]; nativeBuildInputs = [pkg-config];
cargoHash = lib.fakeHash; 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 = { meta = {
description = "TUI underground game"; description = "TUI underground game";
homepage = "https://gitea.garandplg.com/GarandPLG/war-in-tunnels"; homepage = "https://gitea.garandplg.com/GarandPLG/war-in-tunnels";
license = lib.licenses.mit; license = lib.licenses.mit;
maintainers = [ platforms = ["x86_64-linux"];
"Garand_PLG" maintainers = with lib.maintainers; [
GarandPLG
]; ];
mainProgram = "war-in-tunnels";
}; };
} }
+4
View File
@@ -44,6 +44,10 @@
src = ./.; src = ./.;
buildInputs = with pkgs; [alsa-lib]; buildInputs = with pkgs; [alsa-lib];
nativeBuildInputs = with pkgs; [pkg-config]; nativeBuildInputs = with pkgs; [pkg-config];
postInstall = ''
cp -r soundtracks $out/bin
mv $out/bin/war_in_tunnels $out/bin/war-in-tunnels
'';
}; };
}; };
+4
View File
@@ -31,7 +31,9 @@ use ratatui::{
/// # Example /// # Example
/// ///
/// ```rust /// ```rust
/// use war_in_tunnels::app::helpers::block_title::block_title_helper;
/// use ratatui::style::Color; /// use ratatui::style::Color;
/// use ratatui::text::Line;
/// ///
/// let title: Line<'_> = block_title_helper( /// let title: Line<'_> = block_title_helper(
/// &[ /// &[
@@ -89,7 +91,9 @@ pub fn block_title_helper<'a>(texts: &[(&'a str, Color)], separator: Option<&'a
/// # Example /// # Example
/// ///
/// ```rust /// ```rust
/// use war_in_tunnels::app::helpers::block_title::block_single_title_helper;
/// use ratatui::style::Color; /// use ratatui::style::Color;
/// use ratatui::text::Line;
/// ///
/// let title: Line<'_> = block_single_title_helper("Keybindings", Color::Magenta); /// let title: Line<'_> = block_single_title_helper("Keybindings", Color::Magenta);
/// // `title` now represents: [ Keybindings ] with “Keybindings” coloured magenta. /// // `title` now represents: [ Keybindings ] with “Keybindings” coloured magenta.
+1 -1
View File
@@ -1,4 +1,4 @@
mod block_title; pub mod block_title;
mod cells_area; mod cells_area;
mod main_menu_option; mod main_menu_option;
mod zoom_level; mod zoom_level;
+1 -1
View File
@@ -1,6 +1,6 @@
mod app; mod app;
mod buildings; mod buildings;
mod helpers; pub mod helpers;
mod keybind; mod keybind;
mod keybindings; mod keybindings;
mod state; mod state;