From df75cd268a3e1d4472e93c459c22cb17d0cdaf3d Mon Sep 17 00:00:00 2001 From: Lin Jian Date: Tue, 13 Aug 2024 17:59:35 +0800 Subject: [PATCH] kanata: fix hash mismatch on case-insensitive filesystems The code is stolen from samply[1] and slippy[2]. [1]: https://github.com/NixOS/nixpkgs/blob/4877ea239f4d02410c3516101faf35a81af0c30e/pkgs/development/tools/misc/samply/default.nix#L21-L42 [2]: https://github.com/NixOS/nixpkgs/blob/4877ea239f4d02410c3516101faf35a81af0c30e/pkgs/applications/misc/slippy/default.nix#L25-L44 --- pkgs/tools/system/kanata/default.nix | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/pkgs/tools/system/kanata/default.nix b/pkgs/tools/system/kanata/default.nix index d7fe6cdc7dd3..76c6e5ac8097 100644 --- a/pkgs/tools/system/kanata/default.nix +++ b/pkgs/tools/system/kanata/default.nix @@ -3,6 +3,8 @@ , darwin , rustPlatform , fetchFromGitHub +, jq +, moreutils , withCmd ? false }: @@ -17,10 +19,28 @@ rustPlatform.buildRustPackage rec { sha256 = "sha256-eDeGVmh1gI/DhiP6gxJyGH9G9LNH1NHW0+DNuOPUnBY="; }; - cargoHash = - if stdenv.isLinux - then "sha256-gRJdfvb3Q+G7pXpOyKrgozrZPJJbDajC63Kk5QtgX00=" - else "sha256-i9eY8dvteOLYmM+ad1nw+fohec2SPGCGqColXNamEBo="; + cargoHash = "sha256-Om9Thyr10wc39J6adSWgmXtvjckaEW0z68sWxUqa4wc="; + + # the dependency native-windows-gui 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/native-windows-gui + + 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 + ''; + }; buildInputs = lib.optionals stdenv.isDarwin [ darwin.apple_sdk.frameworks.IOKit ];