mirror of
https://github.com/mudler/LocalAI.git
synced 2026-05-29 11:07:18 -04:00
- Strict monotonic Go coverage gate (make test-coverage-check, 45% baseline) run in CI; fixes ginkgo dropping all-but-one coverprofile across multiple recursive roots, builds with -tags auth, and folds in the in-process tests/e2e suite via --coverpkg. - React UI e2e coverage (make test-ui-coverage: vite-plugin-istanbul + nyc, nix-provided Chromium) plus e2e specs for 6 previously-untested pages, and a UI coverage gate (make test-ui-coverage-check) with a small tolerance since e2e line coverage jitters ~0.5pp run-to-run. - pre-commit hook: lint + coverage on Go changes, Playwright e2e + UI coverage gate on react-ui changes; install with make install-hooks. - New Go handler tests (settings, branding), hermetic base64 download test. - fix(ui): model editor reads vram_display (snake_case), so the VRAM estimate renders again; covered by a regression test. Assisted-by: Claude:claude-opus-4-7 Signed-off-by: Richard Palethorpe <io@richiejp.com>
106 lines
3.4 KiB
Nix
106 lines
3.4 KiB
Nix
# Made by Azteczek
|
|
{
|
|
description = "LocalAI flake";
|
|
|
|
inputs = {
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
|
inference-defaults = {
|
|
url = "https://raw.githubusercontent.com/unslothai/unsloth/main/studio/backend/assets/configs/inference_defaults.json";
|
|
flake = false;
|
|
};
|
|
};
|
|
|
|
outputs = { self, nixpkgs, inference-defaults }:
|
|
let
|
|
system = "x86_64-linux";
|
|
pkgs = nixpkgs.legacyPackages.${system};
|
|
in {
|
|
packages.${system}.default = pkgs.buildGoModule {
|
|
pname = "localai";
|
|
version = "custom";
|
|
|
|
src = ./.;
|
|
proxyVendor = true;
|
|
vendorHash = "sha256-6f3adjGsoFXlUtXjBDHP4Mv9jKCOK3aeUXprm0EAVO8=";
|
|
|
|
nativeBuildInputs = with pkgs; [
|
|
pkg-config cmake gcc protobuf go-protobuf protoc-gen-go protoc-gen-go-grpc
|
|
];
|
|
|
|
env = {
|
|
CGO_ENABLED = "0";
|
|
};
|
|
|
|
preBuild = ''
|
|
|
|
PROTO_SOURCE_DIR=$(find . -name "*.proto" -printf "%h" -quit)
|
|
mkdir -p pkg/grpc/proto
|
|
${pkgs.protobuf}/bin/protoc \
|
|
-I=$PROTO_SOURCE_DIR \
|
|
-I. \
|
|
--go_out=pkg/grpc/proto --go_opt=paths=source_relative \
|
|
--go-grpc_out=pkg/grpc/proto --go-grpc_opt=paths=source_relative \
|
|
$PROTO_SOURCE_DIR/*.proto
|
|
|
|
go mod edit -replace github.com/mudler/LocalAI/pkg/grpc/proto=./pkg/grpc/proto
|
|
|
|
mkdir -p core/config/gen_inference_defaults
|
|
cp ${inference-defaults} core/config/gen_inference_defaults/inference_defaults.json
|
|
sed -i '/go:generate/d' core/config/inference_defaults.go || true
|
|
|
|
'';
|
|
|
|
subPackages = [ "cmd/local-ai" ];
|
|
doCheck = false;
|
|
|
|
postInstall = ''
|
|
[ -f $out/bin/local-ai ] && mv $out/bin/local-ai $out/bin/localai
|
|
'';
|
|
};
|
|
|
|
devShells.${system}.default = pkgs.mkShell {
|
|
packages = with pkgs; [
|
|
# Build toolchain (stdenv already provides gcc)
|
|
go
|
|
gnumake
|
|
pkg-config
|
|
cmake
|
|
protobuf
|
|
go-protobuf
|
|
protoc-gen-go
|
|
protoc-gen-go-grpc
|
|
|
|
# React UI build (core/http/react-ui — `make react-ui`)
|
|
nodejs
|
|
bun # alternative to npm, used by `make react-ui-docker`
|
|
chromium # Playwright e2e / UI coverage browser (see PLAYWRIGHT_CHROMIUM_PATH below)
|
|
|
|
# Linting / static analysis (see `make lint`)
|
|
golangci-lint
|
|
gofumpt
|
|
gotools # goimports
|
|
go-tools # staticcheck
|
|
|
|
# Common dev conveniences
|
|
git
|
|
curl
|
|
];
|
|
|
|
shellHook = ''
|
|
# Point Playwright at the nix-provided Chromium instead of its own
|
|
# downloaded build, which can't resolve system libs (libglib-2.0, …)
|
|
# on NixOS. playwright.config.js reads PLAYWRIGHT_CHROMIUM_PATH and
|
|
# the Makefile skips `playwright install` when it's set.
|
|
export PLAYWRIGHT_CHROMIUM_PATH="${pkgs.chromium}/bin/chromium"
|
|
export PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
|
|
|
|
echo "LocalAI dev shell: $(go version), node $(node --version)"
|
|
echo "Build: make build (Go binary + React UI)"
|
|
echo "React UI: make react-ui (npm install && vite build)"
|
|
echo "Lint: make lint (only new issues vs master)"
|
|
echo " or make lint-all (full baseline)"
|
|
'';
|
|
};
|
|
};
|
|
}
|