Unverified Commit 53d915d8 authored by r-vdp's avatar r-vdp
Browse files

atuin: make cargoHash the same on Linux and Darwin

See #308089
parent 81874bfc
Loading
Loading
Loading
Loading
+30 −6
Original line number Diff line number Diff line
@@ -5,6 +5,8 @@
  installShellFiles,
  rustPlatform,
  nixosTests,
  jq,
  moreutils,
}:

rustPlatform.buildRustPackage rec {
@@ -18,12 +20,34 @@ rustPlatform.buildRustPackage rec {
    hash = "sha256-P/q4XYhpXo9kwiltA0F+rQNSlqI+s8TSi5v5lFJWJ/4=";
  };

  # TODO: unify this to one hash because updater do not support this
  cargoHash =
    if stdenv.hostPlatform.isLinux then
      "sha256-JDm7HWMaLSodpOhrR7rm6ZS/ATX/q8fRK+OJ/EKqg3U="
  # the interim crate contains both README.md and readme.md,
  # which causes a hash mismatch on systems with a case-insensitive filesystem.
  # This removes the readme files and updates cargo's checksum file accordingly
  depsExtraArgs = {
    nativeBuildInputs = [
      jq
      moreutils
    ];

    postBuild = ''
      pushd $name/interim

      if [ -e readme.md ]; then
        rm --force --verbose README.md readme.md
        jq 'del(.files."README.md") | del(.files."readme.md")' \
          .cargo-checksum.json -c \
          | sponge .cargo-checksum.json

        popd
      else
      "sha256-mrsqaqJHMyNi3yFDIyAXFBS+LY71VWXE8O7mjvgI6lo=";
        echo "ERROR: the interim crate has been updated"
        echo "When you see this message, please remove the workaround for the interim crate from the atuin nix expression"
        exit 1
      fi
    '';
  };

  cargoHash = "sha256-l8DsQwEJZL9kr9UIpZzebDSRYET2WM8VFwk+O1Qk9oQ=";

  # atuin's default features include 'check-updates', which do not make sense
  # for distribution builds. List all other default features.