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_compat_direct
c/tests/test_compat_direct.exe
result
# oracoli tiny generati (make_glm_oracle.py) e dati benchmark scaricati
c/glm_tiny/
Generated
+3 -3
View File
@@ -20,11 +20,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1784160687,
"narHash": "sha256-iYL/bixrb6FlHFu/gIuBYzq6c6lM5AAXsXNSWXtIgQc=",
"lastModified": 1784280462,
"narHash": "sha256-DtoqIqM7VkR6NxAkcLpMwmi02USwWb3JdmNGLyhthc0=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "4382ed2b7a6839d4280a9b386db49cbc5907414d",
"rev": "293d6abedf0478e681a4dfcfcb35b30fc796a32f",
"type": "github"
},
"original": {
+48 -34
View File
@@ -6,37 +6,49 @@
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
outputs = {
self,
nixpkgs,
flake-utils,
}:
flake-utils.lib.eachDefaultSystem (
system: let
pkgs = import nixpkgs {inherit system;};
# Python with the packages needed by the offline converter tools
pythonEnv = pkgs.python3.withPackages (ps: with ps; [
torch
safetensors
huggingface-hub
numpy
tokenizers
datasets
]);
pythonEnv = pkgs.python3.withPackages (
ps:
with ps; [
torch
safetensors
huggingface-hub
numpy
tokenizers
datasets
]
);
colibri = pkgs.stdenv.mkDerivation {
pname = "colibri";
version = "1.0";
src = ./.;
# 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 ];
nativeBuildInputs = with pkgs; [makeWrapper];
buildInputs = [
pkgs.gcc
pkgs.gmp
buildInputs = with pkgs; [
gcc
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
ARCH = "x86-64-v3";
ARCH =
if pkgs.stdenv.hostPlatform.isx86_64
then "x86-64-v3"
else "native";
buildPhase = ''
runHook preBuild
@@ -56,7 +68,8 @@
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 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/
# $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";
homepage = "https://github.com/JustVugg/colibri";
license = licenses.asl20;
platforms = platforms.linux;
mainProgram = "glm";
platforms = with platforms; linux ++ darwin;
mainProgram = "coli";
};
};
in
rec {
in {
packages = {
default = colibri;
inherit colibri;
@@ -100,23 +112,25 @@
apps = {
default = {
type = "app";
program = "${colibri}/bin/glm";
program = pkgs.lib.getExe colibri;
};
coli = {
glm = {
type = "app";
program = "${colibri}/bin/coli";
program = "${colibri}/share/colibri/glm";
};
};
devShells.default = pkgs.mkShell {
inputsFrom = [ colibri ];
formatter = (import nixpkgs {inherit system;}).alejandra;
packages = [
devShells.default = pkgs.mkShell {
inputsFrom = [colibri];
packages = with pkgs; [
pythonEnv
pkgs.gcc
pkgs.gnumake
pkgs.clang-tools # clangd / clang-tidy for IDE support
pkgs.pkg-config
gcc
gnumake
clang-tools # clangd / clang-tidy for IDE support
pkg-config
];
shellHook = ''