blob: 30b802e3149fb557643b066261572c165e970c2c (
plain)
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
{
lib,
fetchFromGitHub,
linkFarm,
makeWrapper,
rustPlatform,
tree-sitter-grammars,
gitUpdater,
versionCheckHook,
}:
let
# based on https://github.com/NixOS/nixpkgs/blob/aa07b78b9606daf1145a37f6299c6066939df075/pkgs/development/tools/parsing/tree-sitter/default.nix#L85-L104
grammarToAttrSet = drv: {
name = "lib" + (lib.strings.removeSuffix "-grammar" (lib.strings.getName drv)) + ".so";
path = "${drv}/parser";
};
libPath = linkFarm "grammars" (map grammarToAttrSet tree-sitter-grammars.allGrammars);
in
rustPlatform.buildRustPackage rec {
pname = "diffsitter";
version = "0.8.4";
src = fetchFromGitHub {
owner = "afnanenayet";
repo = "diffsitter";
rev = "v${version}";
hash = "sha256-ta7JcSPEgpJwieYvtZnNMFvsYvz4FuxthhmKMYe2XUE=";
fetchSubmodules = false;
};
cargoHash = "sha256-YgVsWiINzEsmUMAi6ttEtXutwNDJA2viXnV5rGdSSxU=";
buildNoDefaultFeatures = true;
buildFeatures = [
"dynamic-grammar-libs"
];
nativeBuildInputs = [
makeWrapper
];
nativeInstallCheckInputs = [
versionCheckHook
];
doInstallCheck = true;
postInstall = ''
# completions are not yet implemented
# so we can safely remove this without installing the completions
rm $out/bin/diffsitter_completions
wrapProgram "$out/bin/diffsitter" \
--prefix LD_LIBRARY_PATH : "${libPath}"
'';
doCheck = false;
# failures:
# tests::diff_hunks_snapshot::_medium_cpp_cpp_false_expects
# tests::diff_hunks_snapshot::_medium_cpp_cpp_true_expects
# tests::diff_hunks_snapshot::_medium_rust_rs_false_expects
# tests::diff_hunks_snapshot::_medium_rust_rs_true_expects
# tests::diff_hunks_snapshot::_short_python_py_true_expects
# tests::diff_hunks_snapshot::_short_rust_rs_true_expects
passthru.updateScript = gitUpdater { rev-prefix = "v"; };
meta = {
homepage = "https://github.com/afnanenayet/diffsitter";
description = "Tree-sitter based AST difftool to get meaningful semantic diffs";
license = lib.licenses.mit;
maintainers = with lib.maintainers; [ bbigras ];
};
}
|