Skip to content

Commit d0c3d7f

Browse files
committed
ty: add local 0.0.21 derivation
1 parent a09ff10 commit d0c3d7f

3 files changed

Lines changed: 98 additions & 7 deletions

File tree

pkgs/modules/python/default.nix

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ let
5858
inherit pkgs python python-ld-library-path;
5959
};
6060

61+
ty = pkgs.callPackage ../../ty { };
62+
6163
sitecustomize = pkgs.callPackage ./sitecustomize.nix { };
6264

6365
uv = pkgs.callPackage ./uv {
@@ -103,9 +105,9 @@ in
103105

104106
replit.dev.languageServers.ty = {
105107
name = "ty";
106-
displayVersion = pkgs.ty.version;
108+
displayVersion = ty.version;
107109
language = "python3";
108-
start = "${pkgs.ty}/bin/ty server";
110+
start = "${ty}/bin/ty server";
109111
};
110112

111113
replit.dev.packagers.upmPython = {

pkgs/modules/ty/default.nix

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
1-
{ pkgs, lib, ... }:
1+
{ pkgs, ... }:
2+
let
3+
ty = pkgs.callPackage ../../ty { };
4+
in
25
{
36
id = "ty";
47
name = "ty LSP";
5-
displayVersion = pkgs.ty.version;
8+
displayVersion = ty.version;
69
description = ''
710
Ty is an extremely fast Python type checker from Astral with an integrated language server.
811
'';
912
replit.dev.languageServers.ty = {
1013
name = "ty";
11-
displayVersion = pkgs.ty.version;
14+
displayVersion = ty.version;
1215
language = "python3";
13-
start = "${pkgs.ty}/bin/ty server";
16+
start = "${ty}/bin/ty server";
1417
};
1518

1619
replit.env = {
17-
PATH = "${pkgs.ty}/bin";
20+
PATH = "${ty}/bin";
1821
};
1922
}

pkgs/ty/default.nix

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
{
2+
lib,
3+
stdenv,
4+
rustPlatform,
5+
fetchFromGitHub,
6+
installShellFiles,
7+
buildPackages,
8+
versionCheckHook,
9+
nix-update-script,
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

Comments
 (0)