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