fix(flake): package engine, support modules, and python for Nix builds (#345)
Four bugs in the Nix flake, all addressed:
1. checkPhase failed with "make: python3: No such file or directory"
because `make test-c` shells out to python3 (c/Makefile: PYTHON ?=
python3) but python3 wasn't in nativeBuildInputs. Add pkgs.python3.
2. `coli serve` reported "engine is not built" even though glm was
packaged, because the engine landed in $out/bin while coli looks for
it beside itself, in libexec/colibri, or via $COLI_ENGINE (c/coli:57-
66). The wrapper now sets COLI_ENGINE to the bundled engine.
3. `coli serve` failed with ModuleNotFoundError: openai_server because
the support modules (openai_server.py, resource_plan.py, doctor.py)
were not installed. Install them and put their dir on PYTHONPATH.
4. Rebuilt the install layout into a self-contained $out/lib/colibri/
that mirrors the source tree coli expects, with $out/bin/{glm,coli}
as user-facing entry points (glm symlinked; coli wrapped).
NOTE: flake.lock is intentionally not included — it must be generated
on a Nix host via `nix flake lock` and committed separately, since it
requires narHash values that only the nix tooling can compute.
This commit is contained in:
@@ -26,7 +26,9 @@
|
||||
version = "1.0";
|
||||
src = ./.;
|
||||
|
||||
nativeBuildInputs = [ pkgs.makeWrapper ];
|
||||
# python3 is needed by checkPhase: `make test-c` shells out to
|
||||
# `python3 tools/run_tests.py` (see c/Makefile, PYTHON ?= python3).
|
||||
nativeBuildInputs = [ pkgs.makeWrapper pkgs.python3 ];
|
||||
|
||||
buildInputs = [
|
||||
pkgs.gcc
|
||||
@@ -44,18 +46,29 @@
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
mkdir -p $out/bin
|
||||
cp c/glm $out/bin/glm
|
||||
|
||||
# Wrap coli (the Python CLI) so it finds the right python and the engine
|
||||
mkdir -p $out/share/colibri
|
||||
cp c/coli $out/share/colibri/coli
|
||||
chmod +x $out/share/colibri/coli
|
||||
cp -r c/tools $out/share/colibri/tools
|
||||
# Self-contained layout under $out/lib/colibri that mirrors the
|
||||
# source tree `coli` runs in (see the path-resolution logic at the
|
||||
# top of c/coli): the engine, the coli CLI script, the support
|
||||
# modules it imports (openai_server.py, resource_plan.py,
|
||||
# doctor.py), and tools/ all sit next to each other.
|
||||
mkdir -p $out/lib/colibri/tools $out/bin
|
||||
cp c/glm $out/lib/colibri/glm
|
||||
cp c/coli $out/lib/colibri/coli
|
||||
chmod +x $out/lib/colibri/coli
|
||||
cp c/openai_server.py c/resource_plan.py c/doctor.py $out/lib/colibri/
|
||||
cp -r c/tools/* $out/lib/colibri/tools/
|
||||
|
||||
# $out/bin holds the user-facing entry points.
|
||||
ln -s ../lib/colibri/glm $out/bin/glm
|
||||
|
||||
# Wrap coli: point it at the bundled engine (COLI_ENGINE) so it is
|
||||
# found by default, and at the module dir (PYTHONPATH) so
|
||||
# `import openai_server` / `resource_plan` / `doctor` resolve.
|
||||
makeWrapper ${pythonEnv}/bin/python $out/bin/coli \
|
||||
--add-flags "$out/share/colibri/coli" \
|
||||
--set PYTHONPATH "${pythonEnv}/${pkgs.python3.sitePackages}"
|
||||
--add-flags "$out/lib/colibri/coli" \
|
||||
--set COLI_ENGINE "$out/lib/colibri/glm" \
|
||||
--set PYTHONPATH "$out/lib/colibri:${pythonEnv}/${pkgs.python3.sitePackages}"
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user