feat: add flake.nix for dockerless setup (#9851)

* Add flake.nix

Signed-off-by: Azteczek <243776410+Azteczek@users.noreply.github.com>

* Add flake.lock

Signed-off-by: Azteczek <243776410+Azteczek@users.noreply.github.com>

---------

Signed-off-by: Azteczek <243776410+Azteczek@users.noreply.github.com>
This commit is contained in:
Azteczek
2026-05-18 16:23:10 +02:00
committed by GitHub
parent 5d0b549049
commit cb502de309
2 changed files with 101 additions and 0 deletions

40
flake.lock generated Normal file
View File

@@ -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
}

61
flake.nix Normal file
View File

@@ -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
'';
};
};
}