1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-18 19:51:17 +00:00
nixpkgs/pkgs/tools/misc/dutree/default.nix
aleksana 1862813d11 treewide: convert cargoSha256 to cargoHash
This is done with the following bash script:

```
#!/usr/bin/env bash
process_line() {
    local filename=${1%:}
    if [[ $4 =~ \"(.*)\"\; ]]; then
      local sha256="${BASH_REMATCH[1]}"
    fi
    [[ -z $sha256 ]] && return 0
    local hash=$(nix hash to-sri --type sha256 $sha256)
    echo "Processing: $filename"
    echo "  $sha256 => $hash"
    sed -i "s|cargoSha256 = \"$sha256\"|cargoHash = \"$hash\"|"
$filename
}

# split output by line
grep -r 'cargoSha256 = ' . | while IFS= read -r line; do
    # split them further by space
    read -r -a parts <<< "$line"
    process_line "${parts[@]}"
done

```
2024-07-03 21:54:10 +08:00

29 lines
819 B
Nix

{ fetchFromGitHub, lib, rustPlatform }:
rustPlatform.buildRustPackage rec {
pname = "dutree";
version = "0.2.18";
src = fetchFromGitHub {
owner = "nachoparker";
repo = pname;
rev = "v${version}";
sha256 = "17lm8jd07bi499mywg2iq669im34j4x4yhc8a3adxn12f8j0dfg7";
# test directory has files with unicode names which causes hash mismatches
# It is also not used by any tests or parts of build process
postFetch = ''
rm -r $out/test
'';
};
cargoHash = "sha256-/E+4yJEhZbERy4vOqn0Ruv3zOcd2FA+q41qZ0Tvg4T0=";
meta = with lib; {
description = "Tool to analyze file system usage written in Rust";
homepage = "https://github.com/nachoparker/dutree";
license = licenses.gpl3Plus;
maintainers = with maintainers; [ figsoda ];
mainProgram = "dutree";
};
}