nixpkgs/pkgs/by-name/di/diffsitter/package.nix
aleksana 571c71e6f7 treewide: migrate packages to pkgs/by-name, take 1
We are migrating packages that meet below requirements:

1. using `callPackage`
2. called path is a directory
3. overriding set is empty (`{ }`)
4. not containing path expressions other than relative path (to
makenixpkgs-vet happy)
5. not referenced by nix files outside of the directory, other
than`pkgs/top-level/all-packages.nix`
6. not referencing nix files outside of the directory
7. not referencing `default.nix` (since it's changed to `package.nix`)
8. `outPath` doesn't change after migration

The tool is here: https://github.com/Aleksanaa/by-name-migrate.
2024-11-09 20:04:51 +08:00

90 lines
2.3 KiB
Nix

{ lib
, fetchFromGitHub
, linkFarm
, makeWrapper
, rustPlatform
, tree-sitter
, gitUpdater
, versionCheckHook
}:
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 "grammars"
(map
(drv:
let
name = lib.strings.getName drv;
in
{
name =
"lib" +
(lib.strings.removeSuffix "-grammar" name)
+ ".so";
path = "${drv}/parser";
}
)
grammars);
libPath = withPlugins (_: tree-sitter.allGrammars);
in
rustPlatform.buildRustPackage rec {
pname = "diffsitter";
version = "0.8.4";
src = fetchFromGitHub {
owner = "afnanenayet";
repo = pname;
rev = "v${version}";
hash = "sha256-ta7JcSPEgpJwieYvtZnNMFvsYvz4FuxthhmKMYe2XUE=";
fetchSubmodules = false;
};
cargoHash = "sha256-VbdV4dftCxxKLJr9TEuCe9tvSGbc62AUwlDZdaNRNhw=";
buildNoDefaultFeatures = true;
buildFeatures = [
"dynamic-grammar-libs"
];
nativeBuildInputs = [
makeWrapper
];
nativeInstallCheckInputs = [
versionCheckHook
];
doInstallCheck = true;
postInstall = ''
# completions are not yet implemented
# so we can safely remove this without installing the completions
rm $out/bin/diffsitter_completions
wrapProgram "$out/bin/diffsitter" \
--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
passthru.updateScript = gitUpdater { rev-prefix = "v"; };
meta = with lib; {
homepage = "https://github.com/afnanenayet/diffsitter";
description = "Tree-sitter based AST difftool to get meaningful semantic diffs";
license = licenses.mit;
maintainers = with maintainers; [ bbigras ];
};
}