Repository navigation
Expand file tree
/
Copy pathflake.nix
More file actions
333 lines (310 loc) · 10.7 KB
/
Copy pathflake.nix
File metadata and controls
333 lines (310 loc) · 10.7 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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
{
description = "Local-first evidence and analysis platform for personal data exports and activity captures";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";
# The separately pinned unstable set supplies Repomix, Python 3.14,
# and the DuckDB CLI matching the Python runtime.
# General workstation tools continue to use the stable package set.
nixpkgsRepomix.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs =
{
self,
nixpkgs,
nixpkgsRepomix,
flake-utils,
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
};
repomixPkgs = import nixpkgsRepomix { inherit system; };
# Package Python deps not in nixpkgs
pythonPackagesBaseOverlay = final: prev: {
cachew = prev.buildPythonPackage rec {
pname = "cachew";
version = "0.22.20251013";
format = "pyproject";
src = prev.fetchPypi {
inherit pname version;
sha256 = "sha256-1ddzhN7j5QHhZ5XEQY21LD89Zt0wxFse18Wh4UcWK2w=";
};
nativeBuildInputs = with prev; [
hatchling
hatch-vcs
];
propagatedBuildInputs = with prev; [
platformdirs
sqlalchemy
orjson
typing-extensions
];
doCheck = false;
};
mcp = prev.buildPythonPackage rec {
pname = "mcp";
version = "1.7.1";
format = "wheel";
src = pkgs.fetchurl {
url = "https://files.pythonhosted.org/packages/ae/79/fe0e20c3358997a80911af51bad927b5ea2f343ef95ab092b19c9cc48b59/mcp-1.7.1-py3-none-any.whl";
sha256 = "0yh563yrqvzr4y3py6bm3csa4nq8rrx6qhlmhi0h6vfvfy4i1rpp";
};
propagatedBuildInputs = with prev; [
anyio
httpx
httpx-sse
pydantic
starlette
sse-starlette
pydantic-settings
uvicorn
python-multipart
];
doCheck = false;
};
claude-agent-sdk = prev.buildPythonPackage rec {
pname = "claude_agent_sdk";
version = "0.1.48";
pyproject = true;
src = prev.fetchPypi {
inherit pname version;
sha256 = "sha256-7ilNPwKTbAuCYRn/vvz4jGdzHPjC0stxEczJf3Y0QnI=";
};
nativeBuildInputs = with prev; [ hatchling ];
# mcp defined in the same overlay — must reference via final, not prev
propagatedBuildInputs = [
prev.anyio
final.mcp
];
doCheck = false;
};
};
pythonPackagesPatchedOverlay =
final: prev:
let
replaceDependency =
name: replacement: input:
if (input.pname or "") == name then replacement else input;
scipy = prev.scipy.overrideAttrs (old: {
disabledTests = (old.disabledTests or [ ]) ++ [
"test_support_moments_sample"
];
});
scikit-learn = prev.scikit-learn.overridePythonAttrs (old: {
build-system = map (replaceDependency "scipy" scipy) (old.build-system or [ ]);
dependencies = map (replaceDependency "scipy" scipy) (old.dependencies or [ ]);
});
hmmlearn = prev.hmmlearn.overridePythonAttrs (old: {
propagatedBuildInputs = map (replaceDependency "scikit-learn" scikit-learn) (
old.propagatedBuildInputs or [ ]
);
# hmmlearn's current tests promote NumPy 2.5 deprecations to
# errors across the matrix. Keep the runtime package while
# upstream updates those assertions.
#
# recheck: when hmmlearn refreshes its NumPy 2.5 test suite.
doCheck = false;
});
inline-snapshot = prev.inline-snapshot.overridePythonAttrs (old: {
# These documentation snapshots encode Black's old multiline
# string layout. Keep the behavioral suite and other doc tests.
# Recheck when inline-snapshot refreshes its Black fixtures.
disabledTests = (old.disabledTests or [ ]) ++ [
"test_docs[categories.md]"
"test_docs[code_generation.md]"
"test_docs[testing.md]"
];
});
# Scope the fixture override to the failing test dependency so
# unrelated Python packages retain their cached derivations.
openai = prev.openai.overridePythonAttrs (old: {
nativeCheckInputs = map (replaceDependency "inline-snapshot" inline-snapshot) (
old.nativeCheckInputs or [ ]
);
nativeInstallCheckInputs = map (replaceDependency "inline-snapshot" inline-snapshot) (
old.nativeInstallCheckInputs or [ ]
);
});
fastapi = prev.fastapi.overridePythonAttrs (_old: {
# FastAPI's current snapshot tests fail against the updated
# inline-snapshot release; this package is consumed for its
# runtime API surface here.
#
# recheck: when FastAPI refreshes its snapshot test suite.
nativeInstallCheckInputs = [ ];
doCheck = false;
});
rich-toolkit = prev.rich-toolkit.overridePythonAttrs (_old: {
# rich-toolkit has the same stale inline-snapshot test edge.
#
# recheck: when rich-toolkit refreshes its snapshot tests.
nativeInstallCheckInputs = [ ];
doCheck = false;
});
in
(pythonPackagesBaseOverlay final prev)
// {
# SciPy 1.18.0 has one property-based test that is invalid under
# NumPy 2.5.1's floating-point behavior: an exact-zero result is
# compared with a tiny non-zero expected value. The runtime
# package remains valid; skip only that stale assertion until
# upstream refreshes it.
#
# recheck: when nixpkgs bumps SciPy past 1.18.0 or refreshes this
# test for NumPy 2.5.
inherit
scipy
scikit-learn
hmmlearn
openai
fastapi
rich-toolkit
;
};
# Development and deployment share Python and dependency corrections.
python = repomixPkgs.python314.override {
packageOverrides = pythonPackagesPatchedOverlay;
};
pythonEnv = python.withPackages (
ps: with ps; [
beautifulsoup4
black
ipython
mypy
types-pyyaml
numpy
rich
scipy
hmmlearn
tqdm
duckdb
cachew
lz4
tiktoken
typer
claude-agent-sdk
cryptography
mcp
polars
pandas
pyyaml
tree-sitter
tree-sitter-python
tree-sitter-rust
pytest
]
);
defaultDevPackages =
(with pkgs; [
pythonEnv
repomixPkgs.duckdb
sqlite
git
gh
jq
yq
repomixPkgs.repomix
ripgrep
fd
just
py-spy
ruff
tokei
haskellPackages.arbtt
])
++ (with pkgs; [
gnumake
]);
heavyAnalysisPackages = with pkgs; [
cargo
semgrep
pip-audit
cargo-machete
cargo-geiger
cargo-audit
];
baseShellHook = profileName: ''
export LYNCHPIN_DEV_PROFILE="${profileName}"
export NIX_CONFIG="max-jobs = ''${LYNCHPIN_NIX_MAX_JOBS:-2}
cores = ''${LYNCHPIN_NIX_CORES:-4}
fallback = true"
export PYTHONUSERBASE=$PWD/.pyuser
export LYNCHPIN_REPO_ROOT="''${LYNCHPIN_REPO_ROOT:-$PWD}"
export PYTHONPATH=$PWD
export PATH="$PWD/tool:$PATH"
'';
mkLynchpinShell =
profileName: packages:
pkgs.mkShell {
name = "sinity-lynchpin-${profileName}";
inherit packages;
shellHook = (baseShellHook profileName) + ''
export LYNCHPIN_DEV_PYTHON="${pythonEnv.pythonVersion}"
if [ "''${LYNCHPIN_MOTD_PRINTED:-0}" != "1" ] && [ -x "$PWD/tool/devshell-motd" ] && { [ -n "''${DIRENV_DIR:-}" ] || [ -t 1 ]; }; then
"$PWD/tool/devshell-motd" >&2
fi
export LYNCHPIN_MOTD_PRINTED=1
'';
};
lynchpinPackage = python.pkgs.buildPythonPackage {
pname = "lynchpin";
version = "0.1.0";
pyproject = true;
src = self;
build-system = with python.pkgs; [
setuptools
];
dependencies = with python.pkgs; [
beautifulsoup4
cachew
claude-agent-sdk
cryptography
duckdb
hmmlearn
mcp
numpy
polars
pandas
pyyaml
rich
scipy
tiktoken
typer
lz4
tree-sitter
tree-sitter-python
tree-sitter-rust
];
pythonImportsCheck = [
"lynchpin"
"lynchpin.cli.current_state"
];
# Import checks run without the workstation's /etc deployment files.
LYNCHPIN_FILESYSTEM_LAYOUT = ./tests/fixtures/capture-layout.json;
doCheck = false;
dontCheckRuntimeDeps = true;
meta = {
description = "Lynchpin analysis/control-plane Python package";
mainProgram = "python";
};
};
lynchpinApiPython = python.withPackages (_: [ lynchpinPackage ]);
in
{
formatter = pkgs.nixfmt-rfc-style;
packages = {
default = lynchpinPackage;
lynchpin = lynchpinPackage;
api-python = lynchpinApiPython;
};
devShells = {
default = mkLynchpinShell "default" defaultDevPackages;
heavy = mkLynchpinShell "heavy" (defaultDevPackages ++ heavyAnalysisPackages);
};
}
);
}