2021-07-20 18:10:15 +00:00
{ lib
, fetchFromGitHub
, linkFarm
, makeWrapper
, rustPlatform
, tree-sitter
} :
let
# based on https://github.com/NixOS/nixpkgs/blob/aa07b78b9606daf1145a37f6299c6066939df075/pkgs/development/tools/parsing/tree-sitter/default.nix#L85-L104
withPlugins = grammarFn :
let
grammars = grammarFn tree-sitter . builtGrammars ;
in
linkFarm " g r a m m a r s "
( map
( drv :
let
name = lib . strings . getName drv ;
in
{
name =
" l i b " +
( lib . strings . removeSuffix " - g r a m m a r " name )
+ " . s o " ;
path = " ${ drv } / p a r s e r " ;
}
)
grammars ) ;
libPath = withPlugins ( _ : tree-sitter . allGrammars ) ;
in
rustPlatform . buildRustPackage rec {
pname = " d i f f s i t t e r " ;
2023-05-12 11:08:04 +00:00
version = " 0 . 8 . 0 " ;
2021-07-20 18:10:15 +00:00
src = fetchFromGitHub {
owner = " a f n a n e n a y e t " ;
repo = pname ;
rev = " v ${ version } " ;
2023-05-12 11:08:04 +00:00
sha256 = " s h a 2 5 6 - K r m K 0 R J d N J c Z G M / 7 I x D P 5 I b J M T Y 3 v 6 M k H A 1 S Q W + U 3 h w = " ;
2021-07-20 18:10:15 +00:00
fetchSubmodules = false ;
} ;
2023-05-12 11:08:04 +00:00
cargoHash = " s h a 2 5 6 - 3 H A L O o a 3 Q D l 9 K E 2 U H x s z z D w / V u D L L m j c c X Q v B B r f r H A = " ;
2021-07-20 18:10:15 +00:00
buildNoDefaultFeatures = true ;
buildFeatures = [
" d y n a m i c - g r a m m a r - l i b s "
] ;
nativeBuildInputs = [
makeWrapper
] ;
postInstall = ''
2023-05-12 13:19:03 +00:00
# completions are not yet implemented
# so we can safely remove this without installing the completions
rm $ out/bin/diffsitter_completions
2021-07-20 18:10:15 +00:00
wrapProgram " $ o u t / b i n / d i f f s i t t e r " \
- - 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
meta = with lib ; {
homepage = " h t t p s : / / g i t h u b . c o m / a f n a n e n a y e t / d i f f s i t t e r " ;
description = " A t r e e - s i t t e r b a s e d A S T d i f f t o o l t o g e t m e a n i n g f u l s e m a n t i c d i f f s " ;
license = licenses . mit ;
maintainers = with maintainers ; [ bbigras ] ;
} ;
}