about summary refs log tree commit diff
path: root/pkgs/tools/text/difftastic/default.nix
blob: b0f88ce32bd396ca69d05729b9d25cfb9b4dfe7a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
{ lib
, rustPlatform
, fetchFromGitHub
, fetchpatch
, testers
, difftastic
}:

rustPlatform.buildRustPackage rec {
  pname = "difftastic";
  version = "0.45.0";

  src = fetchFromGitHub {
    owner = "wilfred";
    repo = pname;
    rev = version;
    sha256 = "sha256-AJwOft5hZoeraDDjwUBsdXn3V+4p8jOGSCYFCEOkWJA=";
  };

  depsExtraArgs = {
    postBuild = let
      mimallocPatch = fetchpatch {
        name = "mimalloc-older-macos-fixes.patch";
        url = "https://github.com/microsoft/mimalloc/commit/40e0507a5959ee218f308d33aec212c3ebeef3bb.patch";
        stripLen = 1;
        extraPrefix = "libmimalloc-sys/c_src/mimalloc/";
        sha256 = "1cqgay6ayzxsj8v1dy8405kwd8av34m4bjc84iyg9r52amlijbg4";
      };
    in ''
      pushd $name
      patch -p1 < ${mimallocPatch}
      substituteInPlace libmimalloc-sys/.cargo-checksum.json \
        --replace \
          '6a2e9f0db0d3de160f9f15ddc8a870dbc42bba724f19f1e69b8c4952cb36821a' \
          '201ab8874d9ba863406e084888e492b785a7edae00a222f395c079028d21a89a' \
        --replace \
          'a87a27e8432a63e5de25703ff5025588afd458e3a573e51b3c3dee2281bff0d4' \
          'ab98a2da81d2145003a9cba7b7025efbd2c7b37c7a23c058c150705a3ec39298'
      popd
    '';
  };
  cargoLock = {
    lockFile = ./Cargo.lock;
    outputHashes = {
      "tree_magic_mini-3.0.2" = "sha256-iIX/DeDbquObDPOx/pctVFN4R8GSkD9bPNkNgOLdUJs=";
    };
  };

  passthru.tests.version = testers.testVersion { package = difftastic; };

  meta = with lib; {
    description = "A syntax-aware diff";
    homepage = "https://github.com/Wilfred/difftastic";
    changelog = "https://github.com/Wilfred/difftastic/blob/${version}/CHANGELOG.md";
    license = licenses.mit;
    maintainers = with maintainers; [ ethancedwards8 figsoda ];
    mainProgram = "difft";
  };
}