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-28 21:21:41 +00:00
version = " 0 . 7 . 3 " ;
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-28 21:21:41 +00:00
sha256 = " s h a 2 5 6 - A J j g n + q F f y 6 / g j b 8 t Q O J D m e v Z y 1 Z f p F 0 n T x A g u n S a b E = " ;
2022-10-21 18:38:19 +00:00
fetchSubmodules = false ;
} ;
2022-12-28 21:21:41 +00:00
cargoSha256 = " s h a 2 5 6 - U / X v l l k z E V t 4 T p D P A 5 g S R K p I I Q a g A T G d H h 7 Y P F O o 4 C Y = " ;
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 ] ;
} ;
}