nixpkgs/pkgs/development/tools/ruff/default.nix

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

67 lines
1.7 KiB
Nix
Raw Normal View History

2022-09-25 16:46:28 +00:00
{ lib
, rustPlatform
, fetchFromGitHub
, installShellFiles
2022-09-25 16:46:28 +00:00
, stdenv
, darwin
2023-05-15 11:16:12 +00:00
# tests
, ruff-lsp
2022-09-25 16:46:28 +00:00
}:
rustPlatform.buildRustPackage rec {
pname = "ruff";
version = "0.0.274";
2022-09-25 16:46:28 +00:00
src = fetchFromGitHub {
owner = "astral-sh";
2022-09-25 16:46:28 +00:00
repo = pname;
rev = "v${version}";
hash = "sha256-0JaeLvc6pwvt9a7wAbah6sVgmHf6GParwdkiW3jQPaQ=";
2022-09-25 16:46:28 +00:00
};
cargoLock = {
lockFile = ./Cargo.lock;
outputHashes = {
"libcst-0.1.0" = "sha256-jG9jYJP4reACkFLrQBWOYH6nbKniNyFVItD0cTZ+nW0=";
"ruff_text_size-0.0.0" = "sha256-qMJ29bkET3JNPeggcA91sXSw2r4bY7rzXtJfY3uy/ws=";
"unicode_names2-0.6.0" = "sha256-eWg9+ISm/vztB0KIdjhq5il2ZnwGJQCleCYfznCI3Wg=";
};
};
nativeBuildInputs = [
installShellFiles
];
2022-09-25 16:46:28 +00:00
buildInputs = lib.optionals stdenv.isDarwin [
darwin.apple_sdk.frameworks.CoreServices
2022-09-25 16:46:28 +00:00
];
cargoBuildFlags = [ "--package=ruff_cli" ];
cargoTestFlags = cargoBuildFlags;
2023-03-30 23:23:28 +00:00
preBuild = lib.optionalString (stdenv.isDarwin && stdenv.isx86_64) ''
# See https://github.com/jemalloc/jemalloc/issues/1997
# Using a value of 48 should work on both emulated and native x86_64-darwin.
export JEMALLOC_SYS_WITH_LG_VADDR=48
'';
postInstall = ''
installShellCompletion --cmd ruff \
--bash <($out/bin/ruff generate-shell-completion bash) \
--fish <($out/bin/ruff generate-shell-completion fish) \
--zsh <($out/bin/ruff generate-shell-completion zsh)
'';
2023-05-15 11:16:12 +00:00
passthru.tests = {
inherit ruff-lsp;
};
2022-09-25 16:46:28 +00:00
meta = with lib; {
description = "An extremely fast Python linter";
homepage = "https://github.com/astral-sh/ruff";
changelog = "https://github.com/astral-sh/ruff/releases/tag/v${version}";
2022-09-25 16:46:28 +00:00
license = licenses.mit;
maintainers = with maintainers; [ figsoda ];
};
}