|
| 1 | +{ lib |
| 2 | +, stdenv |
| 3 | +, rustPlatform |
| 4 | +, fetchFromGitHub |
| 5 | +, installShellFiles |
| 6 | +, buildPackages |
| 7 | +, versionCheckHook |
| 8 | +, nix-update-script |
| 9 | +, |
| 10 | +}: |
| 11 | + |
| 12 | +rustPlatform.buildRustPackage (finalAttrs: { |
| 13 | + pname = "ty"; |
| 14 | + version = "0.0.21"; |
| 15 | + |
| 16 | + src = fetchFromGitHub { |
| 17 | + owner = "astral-sh"; |
| 18 | + repo = "ty"; |
| 19 | + tag = finalAttrs.version; |
| 20 | + fetchSubmodules = true; |
| 21 | + hash = "sha256-/R0nw9V0IhuTxRaZNydvk/xGC5V1gYHQxBkAU/Cjsmw="; |
| 22 | + }; |
| 23 | + |
| 24 | + postPatch = lib.optionalString stdenv.hostPlatform.isDarwin '' |
| 25 | + rm ${finalAttrs.cargoRoot}/crates/ty/tests/file_watching.rs |
| 26 | + ''; |
| 27 | + |
| 28 | + cargoRoot = "ruff"; |
| 29 | + buildAndTestSubdir = finalAttrs.cargoRoot; |
| 30 | + |
| 31 | + cargoBuildFlags = [ "--package=ty" ]; |
| 32 | + |
| 33 | + cargoHash = "sha256-NaWWX6EAVkEg/KQ+Up0t2fh/24fnTo6i5dDZoOWErjg="; |
| 34 | + |
| 35 | + nativeBuildInputs = [ installShellFiles ]; |
| 36 | + |
| 37 | + preCheck = '' |
| 38 | + export CARGO_BIN_EXE_ty="$PWD"/target/${stdenv.hostPlatform.rust.cargoShortTarget}/release/ty |
| 39 | + ''; |
| 40 | + |
| 41 | + cargoTestFlags = [ |
| 42 | + "--package=ty" |
| 43 | + "--package=ty_python_semantic" |
| 44 | + "--package=ty_test" |
| 45 | + ]; |
| 46 | + |
| 47 | + checkFlags = [ |
| 48 | + "--skip=python_environment::ty_environment_and_active_environment" |
| 49 | + "--skip=python_environment::ty_environment_and_discovered_venv" |
| 50 | + "--skip=python_environment::ty_environment_is_only_environment" |
| 51 | + "--skip=python_environment::ty_environment_is_system_not_virtual" |
| 52 | + "--skip=mdtest::generics/pep695/functions.md" |
| 53 | + ]; |
| 54 | + |
| 55 | + nativeInstallCheckInputs = [ versionCheckHook ]; |
| 56 | + doInstallCheck = true; |
| 57 | + |
| 58 | + postInstall = lib.optionalString (stdenv.hostPlatform.emulatorAvailable buildPackages) ( |
| 59 | + let |
| 60 | + emulator = stdenv.hostPlatform.emulator buildPackages; |
| 61 | + in |
| 62 | + '' |
| 63 | + installShellCompletion --cmd ty \ |
| 64 | + --bash <(${emulator} $out/bin/ty generate-shell-completion bash) \ |
| 65 | + --fish <(${emulator} $out/bin/ty generate-shell-completion fish) \ |
| 66 | + --zsh <(${emulator} $out/bin/ty generate-shell-completion zsh) |
| 67 | + '' |
| 68 | + ); |
| 69 | + |
| 70 | + passthru = { |
| 71 | + updateScript = nix-update-script { }; |
| 72 | + }; |
| 73 | + |
| 74 | + meta = { |
| 75 | + description = "Extremely fast Python type checker and language server, written in Rust"; |
| 76 | + homepage = "https://github.com/astral-sh/ty"; |
| 77 | + changelog = "https://github.com/astral-sh/ty/blob/${finalAttrs.version}/CHANGELOG.md"; |
| 78 | + license = lib.licenses.mit; |
| 79 | + mainProgram = "ty"; |
| 80 | + maintainers = with lib.maintainers; [ |
| 81 | + bengsparks |
| 82 | + figsoda |
| 83 | + GaetanLepage |
| 84 | + ]; |
| 85 | + }; |
| 86 | +}) |
0 commit comments