Merge pull request #409 from attilaolah/nix

nix: add darwin support, fix tests, minor changes
This commit is contained in:
Vincenzo Fornaro
2026-07-20 18:11:43 +02:00
committed by GitHub
3 changed files with 52 additions and 37 deletions
+1
View File
@@ -37,6 +37,7 @@ c/tests/test_schema_gbnf
c/tests/test_schema_gbnf.exe c/tests/test_schema_gbnf.exe
c/tests/test_compat_direct c/tests/test_compat_direct
c/tests/test_compat_direct.exe c/tests/test_compat_direct.exe
result
# oracoli tiny generati (make_glm_oracle.py) e dati benchmark scaricati # oracoli tiny generati (make_glm_oracle.py) e dati benchmark scaricati
c/glm_tiny/ c/glm_tiny/
Generated
+3 -3
View File
@@ -20,11 +20,11 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1784160687, "lastModified": 1784280462,
"narHash": "sha256-iYL/bixrb6FlHFu/gIuBYzq6c6lM5AAXsXNSWXtIgQc=", "narHash": "sha256-DtoqIqM7VkR6NxAkcLpMwmi02USwWb3JdmNGLyhthc0=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "4382ed2b7a6839d4280a9b386db49cbc5907414d", "rev": "293d6abedf0478e681a4dfcfcb35b30fc796a32f",
"type": "github" "type": "github"
}, },
"original": { "original": {
+48 -34
View File
@@ -6,37 +6,49 @@
flake-utils.url = "github:numtide/flake-utils"; flake-utils.url = "github:numtide/flake-utils";
}; };
outputs = { self, nixpkgs, flake-utils }: outputs = {
flake-utils.lib.eachDefaultSystem (system: self,
let nixpkgs,
pkgs = import nixpkgs { inherit system; }; flake-utils,
}:
flake-utils.lib.eachDefaultSystem (
system: let
pkgs = import nixpkgs {inherit system;};
# Python with the packages needed by the offline converter tools # Python with the packages needed by the offline converter tools
pythonEnv = pkgs.python3.withPackages (ps: with ps; [ pythonEnv = pkgs.python3.withPackages (
torch ps:
safetensors with ps; [
huggingface-hub torch
numpy safetensors
tokenizers huggingface-hub
datasets numpy
]); tokenizers
datasets
]
);
colibri = pkgs.stdenv.mkDerivation { colibri = pkgs.stdenv.mkDerivation {
pname = "colibri"; pname = "colibri";
version = "1.0"; version = "1.0";
src = ./.; src = ./.;
# python3 is needed by checkPhase: `make test-c` shells out to nativeBuildInputs = with pkgs; [makeWrapper];
# `python3 tools/run_tests.py` (see c/Makefile, PYTHON ?= python3).
nativeBuildInputs = [ pkgs.makeWrapper pkgs.python3 ];
buildInputs = [ buildInputs = with pkgs; [
pkgs.gcc gcc
pkgs.gmp gmp
]; ];
# python3 is needed by checkPhase: `make test-c` shells out to
# `python3 tools/run_tests.py` (see c/Makefile, PYTHON ?= python3).
nativeCheckInputs = with pkgs; [python3];
# Use x86-64-v3 (AVX2) for a portable binary; override with ARCH=native for local builds # Use x86-64-v3 (AVX2) for a portable binary; override with ARCH=native for local builds
ARCH = "x86-64-v3"; ARCH =
if pkgs.stdenv.hostPlatform.isx86_64
then "x86-64-v3"
else "native";
buildPhase = '' buildPhase = ''
runHook preBuild runHook preBuild
@@ -56,7 +68,8 @@
cp c/glm $out/lib/colibri/glm cp c/glm $out/lib/colibri/glm
cp c/coli $out/lib/colibri/coli cp c/coli $out/lib/colibri/coli
chmod +x $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 c/openai_server.py c/resource_plan.py c/doctor.py c/version.py \
$out/lib/colibri/
cp -r c/tools/* $out/lib/colibri/tools/ cp -r c/tools/* $out/lib/colibri/tools/
# $out/bin holds the user-facing entry points. # $out/bin holds the user-facing entry points.
@@ -86,12 +99,11 @@
description = "Run GLM-5.2 (744B MoE) on a consumer machine with ~25 GB RAM"; description = "Run GLM-5.2 (744B MoE) on a consumer machine with ~25 GB RAM";
homepage = "https://github.com/JustVugg/colibri"; homepage = "https://github.com/JustVugg/colibri";
license = licenses.asl20; license = licenses.asl20;
platforms = platforms.linux; platforms = with platforms; linux ++ darwin;
mainProgram = "glm"; mainProgram = "coli";
}; };
}; };
in in {
rec {
packages = { packages = {
default = colibri; default = colibri;
inherit colibri; inherit colibri;
@@ -100,23 +112,25 @@
apps = { apps = {
default = { default = {
type = "app"; type = "app";
program = "${colibri}/bin/glm"; program = pkgs.lib.getExe colibri;
}; };
coli = { glm = {
type = "app"; type = "app";
program = "${colibri}/bin/coli"; program = "${colibri}/share/colibri/glm";
}; };
}; };
devShells.default = pkgs.mkShell { formatter = (import nixpkgs {inherit system;}).alejandra;
inputsFrom = [ colibri ];
packages = [ devShells.default = pkgs.mkShell {
inputsFrom = [colibri];
packages = with pkgs; [
pythonEnv pythonEnv
pkgs.gcc gcc
pkgs.gnumake gnumake
pkgs.clang-tools # clangd / clang-tidy for IDE support clang-tools # clangd / clang-tidy for IDE support
pkgs.pkg-config pkg-config
]; ];
shellHook = '' shellHook = ''