11{
22 lib ,
33 stdenv ,
4- python3Packages ,
5- fetchFromGitHub ,
64 rustPlatform ,
5+ fetchFromGitHub ,
76 installShellFiles ,
7+
88 rust-jemalloc-sys ,
9+ buildPackages ,
910 versionCheckHook ,
1011
1112 # passthru
1415 nix-update-script ,
1516} :
1617
17- python3Packages . buildPythonPackage rec {
18+ rustPlatform . buildRustPackage rec {
1819 pname = "ruff" ;
1920 version = "0.8.4" ;
20- pyproject = true ;
21-
22- outputs = [
23- "bin"
24- "out"
25- ] ;
2621
2722 src = fetchFromGitHub {
2823 owner = "astral-sh" ;
@@ -31,46 +26,29 @@ python3Packages.buildPythonPackage rec {
3126 hash = "sha256-c5d2XaoEjCHWMdjTLD6CnwP8rpSXTUrmKSs0QWQ6UG0=" ;
3227 } ;
3328
34- # Do not rely on path lookup at runtime to find the ruff binary
35- postPatch = ''
36- substituteInPlace python/ruff/__main__.py \
37- --replace-fail \
38- 'ruff_exe = "ruff" + sysconfig.get_config_var("EXE")' \
39- 'return "${ placeholder "bin" } /bin/ruff"'
40- '' ;
29+ useFetchCargoVendor = true ;
30+ cargoHash = "sha256-jbUjsIJRpkKYc+qHN8tkcZrcjPTFJfdCsatezzdX4Ss=" ;
4131
42- cargoDeps = rustPlatform . fetchCargoVendor {
43- inherit pname version src ;
44- hash = "sha256-jbUjsIJRpkKYc+qHN8tkcZrcjPTFJfdCsatezzdX4Ss=" ;
45- } ;
46-
47- nativeBuildInputs =
48- [ installShellFiles ]
49- ++ ( with rustPlatform ; [
50- cargoSetupHook
51- maturinBuildHook
52- cargoCheckHook
53- ] ) ;
32+ nativeBuildInputs = [ installShellFiles ] ;
5433
5534 buildInputs = [
5635 rust-jemalloc-sys
5736 ] ;
5837
5938 postInstall =
39+ let
40+ emulator = stdenv . hostPlatform . emulator buildPackages ;
41+ in
6042 ''
61- mkdir -p $bin/bin
62- mv $out/bin/ruff $bin/bin/
63- rmdir $out/bin
64- ''
65- + lib . optionalString ( stdenv . buildPlatform . canExecute stdenv . hostPlatform ) ''
6643 installShellCompletion --cmd ruff \
67- --bash <($bin /bin/ruff generate-shell-completion bash) \
68- --fish <($bin /bin/ruff generate-shell-completion fish) \
69- --zsh <($bin /bin/ruff generate-shell-completion zsh)
44+ --bash <(${ emulator } $out /bin/ruff generate-shell-completion bash) \
45+ --fish <(${ emulator } $out /bin/ruff generate-shell-completion fish) \
46+ --zsh <(${ emulator } $out /bin/ruff generate-shell-completion zsh)
7047 '' ;
7148
7249 # Run cargo tests
73- cargoCheckType = "debug" ;
50+ checkType = "debug" ;
51+
7452 # tests do not appear to respect linker options on doctests
7553 # Upstream issue: https://github.com/rust-lang/cargo/issues/14189
7654 # This causes errors like "error: linker `cc` not found" on static builds
@@ -106,12 +84,11 @@ python3Packages.buildPythonPackage rec {
10684 "--skip=unix::symlink_inside_workspace"
10785 ] ;
10886
109- nativeCheckInputs = [
87+ nativeInstallCheckInputs = [
11088 versionCheckHook
11189 ] ;
11290 versionCheckProgramArg = [ "--version" ] ;
113-
114- pythonImportsCheck = [ "ruff" ] ;
91+ doInstallCheck = true ;
11592
11693 passthru = {
11794 tests =
0 commit comments