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 " ;
2022-12-02 08:20:57 +00:00
version = " 0 . 7 . 2 " ;
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 } " ;
2022-12-02 08:20:57 +00:00
sha256 = " s h a 2 5 6 - o H G 2 v w 9 8 1 r 9 F Z S w b J + x c L e m f Q S M D r k 6 P A r / q t y I m M 0 4 = " ;
2022-10-21 18:38:19 +00:00
fetchSubmodules = false ;
} ;
2022-12-02 08:20:57 +00:00
cargoSha256 = " s h a 2 5 6 - C j 9 j d e e J N R / 7 m q u E f a Q C s F g i C j y J b Z a a S k O z b U 6 4 T 3 U = " ;
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 = ''
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 ] ;
} ;
}