evcc: 0.131.4 -> 0.131.5
[NixPkgs.git] / pkgs / by-name / di / diffsitter / package.nix
blob6089af84b44baa9834fdc1ab83ba7868e1c8fa62
1 { lib
2 , fetchFromGitHub
3 , linkFarm
4 , makeWrapper
5 , rustPlatform
6 , tree-sitter
7 , gitUpdater
8 , versionCheckHook
9 }:
11 let
12   # based on https://github.com/NixOS/nixpkgs/blob/aa07b78b9606daf1145a37f6299c6066939df075/pkgs/development/tools/parsing/tree-sitter/default.nix#L85-L104
13   withPlugins = grammarFn:
14     let
15       grammars = grammarFn tree-sitter.builtGrammars;
16     in
17     linkFarm "grammars"
18       (map
19         (drv:
20           let
21             name = lib.strings.getName drv;
22           in
23           {
24             name =
25               "lib" +
26               (lib.strings.removeSuffix "-grammar" name)
27               + ".so";
28             path = "${drv}/parser";
29           }
30         )
31         grammars);
33   libPath = withPlugins (_: tree-sitter.allGrammars);
35 rustPlatform.buildRustPackage rec {
36   pname = "diffsitter";
37   version = "0.8.4";
39   src = fetchFromGitHub {
40     owner = "afnanenayet";
41     repo = pname;
42     rev = "v${version}";
43     hash = "sha256-ta7JcSPEgpJwieYvtZnNMFvsYvz4FuxthhmKMYe2XUE=";
44     fetchSubmodules = false;
45   };
47   cargoHash = "sha256-VbdV4dftCxxKLJr9TEuCe9tvSGbc62AUwlDZdaNRNhw=";
49   buildNoDefaultFeatures = true;
50   buildFeatures = [
51     "dynamic-grammar-libs"
52   ];
54   nativeBuildInputs = [
55     makeWrapper
56   ];
58   nativeInstallCheckInputs = [
59     versionCheckHook
60   ];
61   doInstallCheck = true;
63   postInstall = ''
64     # completions are not yet implemented
65     # so we can safely remove this without installing the completions
66     rm $out/bin/diffsitter_completions
68     wrapProgram "$out/bin/diffsitter" \
69       --prefix LD_LIBRARY_PATH : "${libPath}"
70   '';
72   doCheck = false;
73   # failures:
74   #     tests::diff_hunks_snapshot::_medium_cpp_cpp_false_expects
75   #     tests::diff_hunks_snapshot::_medium_cpp_cpp_true_expects
76   #     tests::diff_hunks_snapshot::_medium_rust_rs_false_expects
77   #     tests::diff_hunks_snapshot::_medium_rust_rs_true_expects
78   #     tests::diff_hunks_snapshot::_short_python_py_true_expects
79   #     tests::diff_hunks_snapshot::_short_rust_rs_true_expects
81   passthru.updateScript = gitUpdater { rev-prefix = "v"; };
83   meta = with lib; {
84     homepage = "https://github.com/afnanenayet/diffsitter";
85     description = "Tree-sitter based AST difftool to get meaningful semantic diffs";
86     license = licenses.mit;
87     maintainers = with maintainers; [ bbigras ];
88   };