Files
nixpkgs/pkgs/by-name/as/ast-grep/package.nix
Dark Steveneq 646b892680
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s
push sheeet
2025-10-09 14:15:47 +02:00

72 lines
1.9 KiB
Nix

{
lib,
rustPlatform,
fetchFromGitHub,
stdenv,
installShellFiles,
versionCheckHook,
nix-update-script,
enableLegacySg ? false,
}:
rustPlatform.buildRustPackage (finalAttrs: {
pname = "ast-grep";
version = "0.39.5";
src = fetchFromGitHub {
owner = "ast-grep";
repo = "ast-grep";
tag = finalAttrs.version;
hash = "sha256-hgJD3cc+FbOuI2ZCuKDN2u9vMZngIvPGUqFRjpFE/zY=";
};
# error: linker `aarch64-linux-gnu-gcc` not found
postPatch = ''
rm .cargo/config.toml
'';
cargoHash = "sha256-KLiE1lbgrWj8RYLTFLMqukeH1W9ipE1vYaId2/DJHrE=";
nativeBuildInputs = [ installShellFiles ];
cargoBuildFlags = [
"--package ast-grep --bin ast-grep"
]
++ lib.optionals enableLegacySg [ "--package ast-grep --bin sg" ];
postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
installShellCompletion --cmd ast-grep \
--bash <($out/bin/ast-grep completions bash) \
--fish <($out/bin/ast-grep completions fish) \
--zsh <($out/bin/ast-grep completions zsh)
${lib.optionalString enableLegacySg ''
installShellCompletion --cmd sg \
--bash <($out/bin/sg completions bash) \
--fish <($out/bin/sg completions fish) \
--zsh <($out/bin/sg completions zsh)
''}
'';
nativeInstallCheckInputs = [
versionCheckHook
];
versionCheckProgramArg = "--version";
doInstallCheck = true;
passthru.updateScript = nix-update-script { };
meta = {
mainProgram = "ast-grep";
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/${finalAttrs.version}/CHANGELOG.md";
license = lib.licenses.mit;
maintainers = with lib.maintainers; [
xiaoxiangmoe
montchr
lord-valen
cafkafk
];
};
})