-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
142 lines (118 loc) · 3.96 KB
/
flake.nix
File metadata and controls
142 lines (118 loc) · 3.96 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
{
description = "slopmortem — find similar dead startups, write per-candidate post-mortems";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
pyproject-nix = {
url = "github:pyproject-nix/pyproject.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
uv2nix = {
url = "github:pyproject-nix/uv2nix";
inputs.pyproject-nix.follows = "pyproject-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
pyproject-build-systems = {
url = "github:pyproject-nix/build-system-pkgs";
inputs.pyproject-nix.follows = "pyproject-nix";
inputs.uv2nix.follows = "uv2nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = {
self,
nixpkgs,
flake-utils,
pyproject-nix,
uv2nix,
pyproject-build-systems,
}:
flake-utils.lib.eachDefaultSystem (system: let
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
};
python = pkgs.python313;
workspace = uv2nix.lib.workspace.loadWorkspace {workspaceRoot = ./.;};
overlay = workspace.mkPyprojectOverlay {
sourcePreference = "wheel";
};
pythonSet = (pkgs.callPackage pyproject-nix.build.packages {inherit python;})
.overrideScope (
pkgs.lib.composeManyExtensions [
pyproject-build-systems.overlays.default
overlay
]
);
runtimeLibs = with pkgs;
[
stdenv.cc.cc.lib
zlib
openssl
libxml2
libxslt
]
++ pkgs.lib.optionals pkgs.stdenv.isLinux [
glibc
];
in {
packages.default = pythonSet.mkVirtualEnv "slopmortem-env" workspace.deps.default;
apps.default = {
type = "app";
program = "${self.packages.${system}.default}/bin/slopmortem";
};
devShells.default = pkgs.mkShell {
name = "slopmortem";
# ``python`` (Nix's CPython) is intentionally *not* in this list.
# The dev workflow goes ``uv venv`` → ``uv sync`` → ``uv run`` and uv
# provisions its own standalone CPython under ~/.local/share/uv/python/.
# Reasoning: PyPI wheels (especially the native ones — ``tokenizers``,
# ``onnxruntime``) are built against PSF's standard CPython ABI and
# silently abort when loaded into Nix's CPython. The flake's
# ``packages.default`` (uv2nix mkVirtualEnv) still uses Nix Python and
# is fine for ``nix run .`` consumers, but the dev path swaps in uv's
# Python so PyPI wheels load cleanly.
packages = with pkgs; [
uv
ruff
basedpyright
just
pre-commit
taplo
claude-code
nodejs_25
docker
docker-compose
yq-go
jq
git
git-lfs
curl
zip
];
env = {
# Let uv download + manage Python for the .venv so PyPI wheels
# (especially ``tokenizers``/``onnxruntime``) match the ABI they
# were built against. ``UV_PYTHON`` pins the version uv resolves to;
# uv pulls a python-build-standalone tarball if it's not cached.
UV_PYTHON = "3.13";
UV_PYTHON_DOWNLOADS = "automatic";
UV_PROJECT_ENVIRONMENT = ".venv";
HF_HOME = "./data/hf";
SENTENCE_TRANSFORMERS_HOME = "./data/hf";
};
shellHook = ''
export LD_LIBRARY_PATH="${pkgs.lib.makeLibraryPath runtimeLibs}:''${LD_LIBRARY_PATH:-}"
# ``uv venv`` (no --python pin) honors UV_PYTHON. uv downloads + caches
# its standalone CPython on first invocation; subsequent shells reuse it.
if [ ! -d .venv ]; then
echo "→ creating .venv via uv (uv-managed Python)"
uv venv
fi
if [ -f pyproject.toml ]; then
uv sync --frozen 2>/dev/null || uv sync
fi
'';
};
});
}