Radish alpha
r
rad:z4D5UCArafTzTQpDZNQRuqswh3ury
Radicle desktop app
Radicle
Git
radicle-tauri/build: Allow Specifying Version via `GIT_HEAD`
Open lorenz opened 11 months ago

This now allows setting GIT_HEAD “from the outside” and will gracefully fall back to “unknown” in case there’s any issue figuring out what HEAD refers to.

Also tells Nix about it and bumps MSRV to an unsurprisingly old version.

3 files changed +18 -10 2ae7b656 f9294f01
modified crates/radicle-tauri/Cargo.toml
@@ -4,7 +4,7 @@ version = "0.0.0"
authors = ["Rudolfs Osins <rudolfs@osins.org>", "Sebastian Martinez <me@sebastinez.dev>"]
license = "MIT OR Apache-2.0"
edition = "2021"
-
rust-version = "1.70"
+
rust-version = "1.77"
publish = false

[lib]
modified crates/radicle-tauri/build.rs
@@ -1,12 +1,15 @@
+
use std::env;
use std::process::Command;

fn main() {
-
    let output = Command::new("git")
-
        .args(["rev-parse", "--short", "HEAD"])
-
        .output()
-
        .expect("failed to execute git");
-
    let git_head = String::from_utf8(output.stdout).unwrap();
-
    println!("cargo:rustc-env=GIT_HEAD={}", git_head);
+
    let head = env::var("GIT_HEAD").unwrap_or_else(|_| {
+
        Command::new("git")
+
            .args(["rev-parse", "--short", "HEAD"])
+
            .output()
+
            .map(|output| String::from_utf8(output.stdout).expect("output from Git is UTF-8"))
+
            .unwrap_or("unknown".into())
+
    });
+
    println!("cargo::rustc-env=GIT_HEAD={head}");

    tauri_build::build()
}
modified flake.nix
@@ -21,7 +21,7 @@
    heartwood,
    nix-playwright-browsers,
    ...
-
  }@inputs:
+
  }:
    (flake-utils.lib.eachDefaultSystem (system: let
      pkgs = import nixpkgs {
        inherit system;
@@ -30,7 +30,6 @@
          nix-playwright-browsers.overlays.${system}.default
        ];
      };
-
      inherit (pkgs) lib;
    in {

      checks = {
@@ -131,7 +130,13 @@
              PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD = 1;
              PLAYWRIGHT_SKIP_VALIDATE_HOST_REQUIREMENTS = true;
              RUST_SRC_PATH = "${rTc}/lib/rustlib/src/rust/library";
-
            };
+
            } // (
+
              if self ? rev || self ? dirtyRev
+
              then {
+
                GIT_HEAD = self.rev or self.dirtyRev;
+
              }
+
              else {}
+
            );

            preCheck = ''
              export RAD_HOME="$PWD/_rad-home"