From edfd9ec22e9eb06763895a3bc57b23082deecf21 Mon Sep 17 00:00:00 2001 From: Azteczek <243776410+Azteczek@users.noreply.github.com> Date: Sat, 16 May 2026 14:23:43 +0200 Subject: [PATCH 1/2] Add flake.nix Signed-off-by: Azteczek <243776410+Azteczek@users.noreply.github.com> --- flake.nix | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 flake.nix diff --git a/flake.nix b/flake.nix new file mode 100644 index 000000000000..f2f7ad08e187 --- /dev/null +++ b/flake.nix @@ -0,0 +1,61 @@ +# 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 = ./sources; + proxyVendor = true; + vendorHash = "sha256-MdadwbUc2pwfpC9ScsiIfjGIcAOgcwSm6rt/KNlTIuA="; + + 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 + ''; + }; + }; +} From 09dedc1ef008067f11e8ae86d7ce947bee0163ee Mon Sep 17 00:00:00 2001 From: Azteczek <243776410+Azteczek@users.noreply.github.com> Date: Sat, 16 May 2026 14:24:24 +0200 Subject: [PATCH 2/2] Add flake.lock Signed-off-by: Azteczek <243776410+Azteczek@users.noreply.github.com> --- flake.lock | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 flake.lock diff --git a/flake.lock b/flake.lock new file mode 100644 index 000000000000..d67f054165ed --- /dev/null +++ b/flake.lock @@ -0,0 +1,40 @@ +{ + "nodes": { + "inference-defaults": { + "flake": false, + "locked": { + "narHash": "sha256-ygWIkY2xiUEWqAZQM4/0vBz8vWd/RKX5VBj7EHovU14=", + "type": "file", + "url": "https://raw.githubusercontent.com/unslothai/unsloth/main/studio/backend/assets/configs/inference_defaults.json" + }, + "original": { + "type": "file", + "url": "https://raw.githubusercontent.com/unslothai/unsloth/main/studio/backend/assets/configs/inference_defaults.json" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1777578337, + "narHash": "sha256-Ad49moKWeXtKBJNy2ebiTQUEgdLyvGmTeykAQ9xM+Z4=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "15f4ee454b1dce334612fa6843b3e05cf546efab", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "inference-defaults": "inference-defaults", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +}