Skip to content

Commit cb502de

Browse files
authored
feat: add flake.nix for dockerless setup (mudler#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>
1 parent 5d0b549 commit cb502de

2 files changed

Lines changed: 101 additions & 0 deletions

File tree

flake.lock

Lines changed: 40 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Made by Azteczek
2+
{
3+
description = "LocalAI flake";
4+
5+
inputs = {
6+
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
7+
inference-defaults = {
8+
url = "https://raw.githubusercontent.com/unslothai/unsloth/main/studio/backend/assets/configs/inference_defaults.json";
9+
flake = false;
10+
};
11+
};
12+
13+
outputs = { self, nixpkgs, inference-defaults }:
14+
let
15+
system = "x86_64-linux";
16+
pkgs = nixpkgs.legacyPackages.${system};
17+
in {
18+
packages.${system}.default = pkgs.buildGoModule {
19+
pname = "localai";
20+
version = "custom";
21+
22+
src = ./sources;
23+
proxyVendor = true;
24+
vendorHash = "sha256-MdadwbUc2pwfpC9ScsiIfjGIcAOgcwSm6rt/KNlTIuA=";
25+
26+
nativeBuildInputs = with pkgs; [
27+
pkg-config cmake gcc protobuf go-protobuf protoc-gen-go protoc-gen-go-grpc
28+
];
29+
30+
env = {
31+
CGO_ENABLED = "0";
32+
};
33+
34+
preBuild = ''
35+
36+
PROTO_SOURCE_DIR=$(find . -name "*.proto" -printf "%h" -quit)
37+
mkdir -p pkg/grpc/proto
38+
${pkgs.protobuf}/bin/protoc \
39+
-I=$PROTO_SOURCE_DIR \
40+
-I. \
41+
--go_out=pkg/grpc/proto --go_opt=paths=source_relative \
42+
--go-grpc_out=pkg/grpc/proto --go-grpc_opt=paths=source_relative \
43+
$PROTO_SOURCE_DIR/*.proto
44+
45+
go mod edit -replace github.com/mudler/LocalAI/pkg/grpc/proto=./pkg/grpc/proto
46+
47+
mkdir -p core/config/gen_inference_defaults
48+
cp ${inference-defaults} core/config/gen_inference_defaults/inference_defaults.json
49+
sed -i '/go:generate/d' core/config/inference_defaults.go || true
50+
51+
'';
52+
53+
subPackages = [ "cmd/local-ai" ];
54+
doCheck = false;
55+
56+
postInstall = ''
57+
[ -f $out/bin/local-ai ] && mv $out/bin/local-ai $out/bin/localai
58+
'';
59+
};
60+
};
61+
}

0 commit comments

Comments
 (0)