nixpkgs/pkgs/by-name/as/ast-grep/package.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

58 lines
2.0 KiB
Nix
Raw Normal View History

2023-05-12 23:23:33 +00:00
{ lib
, rustPlatform
, fetchFromGitHub
2023-05-19 15:11:51 +00:00
, stdenv
2024-03-09 08:25:38 +00:00
, installShellFiles
2023-05-12 23:23:33 +00:00
}:
2023-05-19 15:11:51 +00:00
2023-05-12 23:23:33 +00:00
rustPlatform.buildRustPackage rec {
pname = "ast-grep";
version = "0.28.1";
2023-05-12 23:23:33 +00:00
src = fetchFromGitHub {
owner = "ast-grep";
repo = "ast-grep";
2023-06-20 04:17:53 +00:00
rev = version;
hash = "sha256-nMOj/oMJsBB0bI2RzxEytvEr0v+VmGIMY0uiK7ALEHM=";
2023-05-12 23:23:33 +00:00
};
cargoHash = "sha256-alOLdkgyrJQNg/JACredGmfs/dKxnOm9cSahvVBHzTM=";
2023-05-12 23:23:33 +00:00
2024-03-09 08:25:38 +00:00
nativeBuildInputs = [ installShellFiles ];
2023-05-19 15:09:09 +00:00
# error: linker `aarch64-linux-gnu-gcc` not found
postPatch = ''
rm .cargo/config.toml
'';
postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
2024-03-09 08:25:38 +00:00
installShellCompletion --cmd sg \
--bash <($out/bin/sg completions bash) \
--fish <($out/bin/sg completions fish) \
--zsh <($out/bin/sg completions zsh)
'';
checkFlags = [
# disable flaky test
"--skip=test::test_load_parser_mac"
# BUG: Broke by 0.12.1 update (https://github.com/NixOS/nixpkgs/pull/257385)
# Please check if this is fixed in future updates of the package
"--skip=verify::test_case::tests::test_unmatching_id"
] ++ lib.optionals (with stdenv.hostPlatform; (isDarwin && isx86_64) || (isLinux && isAarch64)) [
# x86_64-darwin: source/benches/fixtures/json-mac.so\' (no such file), \'/private/tmp/nix-build-.../source/benches/fixtures/json-mac.so\' (mach-o file, but is an incompatible architecture (have \'arm64\', need \'x86_64h\' or \'x86_64\'))" })
# aarch64-linux: /build/source/benches/fixtures/json-linux.so: cannot open shared object file: No such file or directory"
"--skip=test::test_load_parser"
"--skip=test::test_register_lang"
2023-05-19 15:11:51 +00:00
];
2023-05-12 23:23:33 +00:00
meta = with lib; {
mainProgram = "sg";
description = "Fast and polyglot tool for code searching, linting, rewriting at large scale";
homepage = "https://ast-grep.github.io/";
changelog = "https://github.com/ast-grep/ast-grep/blob/${src.rev}/CHANGELOG.md";
license = licenses.mit;
maintainers = with maintainers; [ montchr lord-valen cafkafk ];
2023-05-12 23:23:33 +00:00
};
}