2022-10-21 18:38:19 +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-08-10 07:59:29 +00:00
version = " 0 . 8 . 1 " ;
2022-10-21 18:38:19 +00:00
src = fetchFromGitHub {
owner = " a f n a n e n a y e t " ;
repo = pname ;
rev = " v ${ version } " ;
2023-08-10 07:59:29 +00:00
sha256 = " s h a 2 5 6 - 8 n K Z 8 z c Z S S F 7 Q d 3 6 k A 9 I Q j i o + T I h l Q W R g M q K r s d I n j 4 = " ;
2022-10-21 18:38:19 +00:00
fetchSubmodules = false ;
} ;
2023-08-10 07:59:29 +00:00
cargoHash = " s h a 2 5 6 - L E B A M b 9 t R O p j r W E f u c w + 2 Z a y t n o y J E 4 7 7 I H 3 M y e U G E A = " ;
2022-10-21 18:38:19 +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-24 13:37:59 +00:00
# completions are not yet implemented
# so we can safely remove this without installing the completions
rm $ out/bin/diffsitter_completions
2022-10-21 18:38:19 +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 ] ;
} ;
}