Unverified Commit c0bc7723 authored by Peder Bergebakken Sundt's avatar Peder Bergebakken Sundt Committed by GitHub
Browse files

sus-compiler: 0.2.1 -> 0.3.0-unstable-2025-08-28 (#439165)

parents afd52fc5 3cea104d
Loading
Loading
Loading
Loading
+590 −243

File changed.

Preview size limit exceeded, changes collapsed.

+24 −0
Original line number Diff line number Diff line
diff --git i/build.rs w/build.rs
index 2174a43..cf93c2f 100644
--- i/build.rs
+++ w/build.rs
@@ -14,17 +14,8 @@ fn main() {
     // Print the path to make it available during the build
     println!("cargo:rustc-env=SUS_HOME={}", home_dir.to_str().unwrap());
 
-    // note: add error checking yourself.
-    let output = std::process::Command::new("git")
-        .args(["rev-parse", "HEAD"])
-        .output()
-        .unwrap();
-    let git_hash = String::from_utf8(output.stdout).unwrap();
-    println!("cargo:rustc-env=GIT_HASH={}", git_hash);
-    println!(
-        "cargo:rustc-env=BUILD_DATE={}",
-        chrono::Local::now().to_rfc3339_opts(chrono::SecondsFormat::Secs, false)
-    );
+    println!("cargo:rustc-env=GIT_HASH=@GIT_HASH@");
+    println!("cargo:rustc-env=BUILD_DATE=@GIT_DATE@");
 }
 
 fn get_sus_dir() -> PathBuf {
+34 −4
Original line number Diff line number Diff line
{
  lib,
  stdenv,
  rustPlatform,
  fetchFromGitHub,
  versionCheckHook,
@@ -8,14 +9,33 @@

rustPlatform.buildRustPackage (finalAttrs: {
  pname = "sus-compiler";
  version = "0.2.1";
  version = "0.3.0-unstable-2025-08-28";

  src = fetchFromGitHub {
    owner = "pc2";
    repo = "sus-compiler";
    tag = "v${finalAttrs.version}";
    hash = "sha256-dQef5TiOV33lnNl7XKl7TlCY0E2sEclehWOmy2uvISY=";
    rev = "bc46d911a71d0248a88586c10057206ffadc82ca";
    hash = "sha256-Wnj303B4G09qGOecZfFsicjNcfRkISfo9JDYJeFubVM=";
    fetchSubmodules = true;
    leaveDotGit = true;

    # Manual patch phase with replacement of Git details just before they're deleted.
    postFetch = ''
      cp ${./build.rs.patch} build.rs.patch
      PATCH="$(realpath build.rs.patch)"

      cd "$out"

      GIT_HASH="$(git rev-parse HEAD)"
      GIT_DATE="$(git log --pretty=format:'%ad' --date=iso-strict HEAD -1)"

      substituteInPlace "$PATCH" \
        --replace-fail "@GIT_HASH@" "$GIT_HASH" \
        --replace-fail "@GIT_DATE@" "$GIT_DATE"
      patch -p1 < "$PATCH"

      find "$out" -name .git -print0 | xargs -0 rm -rf
    '';
  };

  # no lockfile upstream
@@ -29,9 +49,19 @@ rustPlatform.buildRustPackage (finalAttrs: {
    ln -s ${./Cargo.lock} Cargo.lock
  '';

  doInstallCheck = true;
  # Do the install version check only on stable versions of this compiler, when the build platform
  # is able to execute the binaries. Unstable versions report a "-devel" string instead of agreeing
  # with the nixpkgs version scheme.
  doInstallCheck =
    let
      isStable = !lib.elem "unstable" (lib.versions.splitVersion finalAttrs.version);
      canExecute = stdenv.buildPlatform.canExecute stdenv.hostPlatform;
    in
    isStable && canExecute;

  nativeInstallCheckInputs = [ versionCheckHook ];
  versionCheckProgram = "${placeholder "out"}/bin/sus_compiler";
  versionCheckProgramArg = "--version";

  updateScript = nix-update-script { extraArgs = [ "--generate-lockfile" ]; };