diff --git a/build.rs b/build.rs index e3a7e57..48d1848 100644 --- a/build.rs +++ b/build.rs @@ -1,4 +1,18 @@ +use std::process::Command; + fn main() { + // commit hash + let git_describe = Command::new("git") + .arg("describe") + .arg("--always") + .arg("--dirty") + .arg("--tags") + .output() + .unwrap(); + + let git_describe = String::from_utf8(git_describe.stdout).unwrap(); + println!("cargo::rustc-env=GIT_DESCRIBE={git_describe}"); + // composite_templates #[cfg(feature = "gtk")] glib_build_tools::compile_resources( diff --git a/flake.nix b/flake.nix index 83120a5..2ad40b5 100644 --- a/flake.nix +++ b/flake.nix @@ -53,7 +53,7 @@ libadwaita librsvg xorg.libXtst - ] ++ lib.optionals stdenv.isDarwin + ] ++ lib.optionals stdenv.isDarwin (with darwin.apple_sdk_11_0.frameworks; [ CoreGraphics ApplicationServices diff --git a/nix/default.nix b/nix/default.nix index bb8e02c..7d93119 100644 --- a/nix/default.nix +++ b/nix/default.nix @@ -12,6 +12,7 @@ rustPlatform.buildRustPackage { version = version; nativeBuildInputs = with pkgs; [ + git pkg-config cmake makeWrapper diff --git a/src/config.rs b/src/config.rs index 1c2e499..5a32c88 100644 --- a/src/config.rs +++ b/src/config.rs @@ -50,7 +50,7 @@ impl ConfigToml { } #[derive(Parser, Debug)] -#[command(author, version, about, long_about = None)] +#[command(author, version=env!("GIT_DESCRIBE"), about, long_about = None)] struct CliArgs { /// the listen port for lan-mouse #[arg(short, long)]