-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathdefault.nix
More file actions
149 lines (130 loc) · 3.56 KB
/
default.nix
File metadata and controls
149 lines (130 loc) · 3.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
{ python, pypkgs }:
{ pkgs-unstable
, lib
, ...
}:
let
pythonVersion = lib.versions.majorMinor python.version;
pkgs = pkgs-unstable;
pylibs-dir = ".pythonlibs";
userbase = "$REPL_HOME/${pylibs-dir}";
pythonUtils = import ../../python-utils {
inherit pkgs python pypkgs;
};
pythonWrapper = pythonUtils.pythonWrapper;
python-ld-library-path = pythonUtils.python-ld-library-path;
pip = import ./pip.nix (
pkgs
// {
inherit python pypkgs;
}
);
pip-wrapper = pythonWrapper {
bin = "${pip.pip}/bin/pip";
name = "pip";
};
poetry = pkgs.callPackage (../../poetry/poetry-py + "${pythonVersion}.nix") {
inherit python;
inherit pypkgs;
};
poetry-config = pkgs.writeTextFile {
name = "poetry-config";
text = "";
destination = "/config.toml";
};
python3-wrapper = pythonWrapper {
bin = "${python}/bin/python3";
name = "python3";
aliases = [
"python"
"python${pythonVersion}"
];
};
poetry-wrapper = pythonWrapper {
bin = "${poetry}/bin/poetry";
name = "poetry";
};
binary-wrapped-python = pkgs.callPackage ../../python-wrapped {
inherit pkgs python python-ld-library-path;
};
ty = pkgs.callPackage ../../ty { };
sitecustomize = pkgs.callPackage ./sitecustomize.nix { };
uv = pkgs.callPackage ./uv {
rustPlatform = (
let
toolchain = pkgs.fenix.latest.toolchain;
in
pkgs.makeRustPlatform {
cargo = toolchain;
rustc = toolchain;
}
);
};
in
{
id = "python-${pythonVersion}";
name = "Python Tools";
displayVersion = pythonVersion;
description = ''
Development tools for Python. Includes Python interpreter, Pip, Poetry, and the ty language server.
'';
replit.packages = [
binary-wrapped-python
pip-wrapper
poetry-wrapper
uv
];
replit.runners.python = {
name = "Python ${pythonVersion}";
displayVersion = python.version;
fileParam = true;
language = "python3";
start = "${python3-wrapper}/bin/python3 $file";
defaultEntrypoints = [
"main.py"
"app.py"
"run.py"
];
};
replit.dev.languageServers.ty = {
name = "ty";
displayVersion = ty.version;
language = "python3";
start = "${ty}/bin/ty server";
};
replit.dev.packagers.upmPython = {
name = "Python packager";
language = "python3";
ignoredPackages = [ "unit_tests" ];
ignoredPaths = [ pylibs-dir ];
features = {
packageSearch = true;
guessImports = true;
enabledForHosting = false;
};
};
replit.env = {
POETRY_CONFIG_DIR = poetry-config.outPath;
POETRY_CACHE_DIR = "$REPL_HOME/.cache/pypoetry";
POETRY_VIRTUALENVS_CREATE = "0";
POETRY_INSTALLER_MODERN_INSTALLATION = "1";
POETRY_DOWNLOAD_WITH_CURL = "1";
POETRY_PIP_USE_PIP_CACHE = "1";
POETRY_PIP_NO_ISOLATE = "1";
POETRY_PIP_NO_PREFIX = "1";
POETRY_PIP_FROM_PATH = "1";
POETRY_USE_USER_SITE = "1";
PIP_CONFIG_FILE = pip.config.outPath;
PYTHONUSERBASE = userbase;
PYTHONPATH = "${sitecustomize}:${pip.pip}/${python.sitePackages}";
REPLIT_PYTHONPATH = "${userbase}/${python.sitePackages}:${pypkgs.setuptools}/${python.sitePackages}";
UV_PROJECT_ENVIRONMENT = "$REPL_HOME/.pythonlibs";
UV_PYTHON_DOWNLOADS = "never";
UV_PYTHON_PREFERENCE = "only-system";
# Even though it is set-default in the wrapper, add it to the
# environment too, so that when someone wants to override it,
# they can keep the defaults if they want to.
REPLIT_PYTHON_LD_LIBRARY_PATH = python-ld-library-path;
PATH = "${userbase}/bin";
};
}