Files
nixpkgs/pkgs/by-name/ru/ruff/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

103 lines
2.8 KiB
Nix

{
lib,
stdenv,
rustPlatform,
fetchFromGitHub,
installShellFiles,
rust-jemalloc-sys,
buildPackages,
versionCheckHook,
# passthru
nixosTests,
nix-update-script,
}:
rustPlatform.buildRustPackage (finalAttrs: {
pname = "ruff";
version = "0.13.1";
src = fetchFromGitHub {
owner = "astral-sh";
repo = "ruff";
tag = finalAttrs.version;
hash = "sha256-dCxCpJLG2qjfrMxDJOL4rCwdVYfrz3P+4kDQ9d9Mbus=";
};
cargoBuildFlags = [ "--package=ruff" ];
cargoHash = "sha256-WtRryq8bmKfL3EL2kRFFokmG2f0lnS6zRMbUzGeYLDM=";
nativeBuildInputs = [ installShellFiles ];
buildInputs = [
rust-jemalloc-sys
];
postInstall = lib.optionalString (stdenv.hostPlatform.emulatorAvailable buildPackages) (
let
emulator = stdenv.hostPlatform.emulator buildPackages;
in
''
installShellCompletion --cmd ruff \
--bash <(${emulator} $out/bin/ruff generate-shell-completion bash) \
--fish <(${emulator} $out/bin/ruff generate-shell-completion fish) \
--zsh <(${emulator} $out/bin/ruff generate-shell-completion zsh)
''
);
# Run cargo tests
checkType = "debug";
# tests do not appear to respect linker options on doctests
# Upstream issue: https://github.com/rust-lang/cargo/issues/14189
# This causes errors like "error: linker `cc` not found" on static builds
doCheck = !stdenv.hostPlatform.isStatic;
# Exclude tests from `ty`-related crates, run everything else.
# Ordinarily we would run all the tests, but there is significant overlap with the `ty` package in nixpkgs,
# which ruff shares a monorepo with.
# As such, we leave running `ty` tests to the `ty` package, and concentrate on everything else.
cargoTestFlags = [
"--workspace"
"--exclude=ty"
"--exclude=ty_ide"
"--exclude=ty_project"
"--exclude=ty_python_semantic"
"--exclude=ty_server"
"--exclude=ty_static"
"--exclude=ty_test"
"--exclude=ty_vendored"
"--exclude=ty_wasm"
];
nativeInstallCheckInputs = [
versionCheckHook
];
versionCheckProgramArg = "--version";
doInstallCheck = true;
passthru = {
tests = lib.optionalAttrs stdenv.hostPlatform.isLinux {
nixos-test-driver-busybox = nixosTests.nixos-test-driver.busybox;
};
# Updating `ruff` needs to be done on staging due to NixOS tests. Disabling r-ryantm update bot:
# nixpkgs-update: no auto update
updateScript = nix-update-script { };
};
meta = {
description = "Extremely fast Python linter and code formatter";
homepage = "https://github.com/astral-sh/ruff";
changelog = "https://github.com/astral-sh/ruff/releases/tag/${finalAttrs.version}";
license = lib.licenses.mit;
mainProgram = "ruff";
maintainers = with lib.maintainers; [
bengsparks
figsoda
GaetanLepage
];
};
})