2022-09-30 11:47:45 +00:00
|
|
|
{ lib
|
|
|
|
, rustPlatform
|
|
|
|
, fetchFromGitHub
|
2023-02-02 18:25:31 +00:00
|
|
|
, installShellFiles
|
2022-09-30 11:47:45 +00:00
|
|
|
, stdenv
|
2022-12-28 21:21:41 +00:00
|
|
|
, darwin
|
2023-05-24 13:37:59 +00:00
|
|
|
# tests
|
|
|
|
, ruff-lsp
|
2022-09-30 11:47:45 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
rustPlatform.buildRustPackage rec {
|
|
|
|
pname = "ruff";
|
2023-08-04 22:07:22 +00:00
|
|
|
version = "0.0.282";
|
2022-09-30 11:47:45 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
2023-07-15 17:15:38 +00:00
|
|
|
owner = "astral-sh";
|
2022-09-30 11:47:45 +00:00
|
|
|
repo = pname;
|
|
|
|
rev = "v${version}";
|
2023-08-04 22:07:22 +00:00
|
|
|
hash = "sha256-CQsgRTpZTBj07/9SYkrQXtb5FOguCtf5LCli65v20YA=";
|
2022-09-30 11:47:45 +00:00
|
|
|
};
|
|
|
|
|
2023-03-24 00:07:29 +00:00
|
|
|
cargoLock = {
|
|
|
|
lockFile = ./Cargo.lock;
|
|
|
|
outputHashes = {
|
2023-07-15 17:15:38 +00:00
|
|
|
"libcst-0.1.0" = "sha256-FgQE8ofRXQs/zHh7AKscXu0deN3IG+Nk/h+a09Co5R8=";
|
2023-03-24 00:07:29 +00:00
|
|
|
"unicode_names2-0.6.0" = "sha256-eWg9+ISm/vztB0KIdjhq5il2ZnwGJQCleCYfznCI3Wg=";
|
|
|
|
};
|
|
|
|
};
|
2023-02-02 18:25:31 +00:00
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
installShellFiles
|
|
|
|
];
|
2022-09-30 11:47:45 +00:00
|
|
|
|
|
|
|
buildInputs = lib.optionals stdenv.isDarwin [
|
2022-12-28 21:21:41 +00:00
|
|
|
darwin.apple_sdk.frameworks.CoreServices
|
2022-09-30 11:47:45 +00:00
|
|
|
];
|
|
|
|
|
2023-03-24 00:07:29 +00:00
|
|
|
cargoBuildFlags = [ "--package=ruff_cli" ];
|
2023-04-12 12:48:02 +00:00
|
|
|
cargoTestFlags = cargoBuildFlags;
|
2023-03-24 00:07:29 +00:00
|
|
|
|
2023-04-12 12:48:02 +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
|
|
|
|
'';
|
2022-12-28 21:21:41 +00:00
|
|
|
|
2023-08-04 22:07:22 +00:00
|
|
|
# tests expect no colors
|
|
|
|
preCheck = ''
|
|
|
|
export NO_COLOR=1
|
|
|
|
'';
|
|
|
|
|
2023-02-02 18:25:31 +00:00
|
|
|
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-24 13:37:59 +00:00
|
|
|
passthru.tests = {
|
|
|
|
inherit ruff-lsp;
|
|
|
|
};
|
|
|
|
|
2022-09-30 11:47:45 +00:00
|
|
|
meta = with lib; {
|
|
|
|
description = "An extremely fast Python linter";
|
2023-07-15 17:15:38 +00:00
|
|
|
homepage = "https://github.com/astral-sh/ruff";
|
|
|
|
changelog = "https://github.com/astral-sh/ruff/releases/tag/v${version}";
|
2022-09-30 11:47:45 +00:00
|
|
|
license = licenses.mit;
|
|
|
|
maintainers = with maintainers; [ figsoda ];
|
|
|
|
};
|
|
|
|
}
|