From b538071f23d8bcb35d6b6b4a7fae740d97c7ac6f Mon Sep 17 00:00:00 2001 From: Souheab Date: Thu, 18 Jun 2026 18:40:23 -0400 Subject: [PATCH 1/5] Use inference defaults in repo src rather than fetching there are inference_defaults.json already in the repo so we can use those, they are regularly updated with github actions, and we avoid hash mismatch errors in the flake this way Signed-off-by: Souheab --- flake.lock | 13 ------------- flake.nix | 8 +------- 2 files changed, 1 insertion(+), 20 deletions(-) diff --git a/flake.lock b/flake.lock index d67f054165ed..25b0fc536406 100644 --- a/flake.lock +++ b/flake.lock @@ -1,17 +1,5 @@ { "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, @@ -30,7 +18,6 @@ }, "root": { "inputs": { - "inference-defaults": "inference-defaults", "nixpkgs": "nixpkgs" } } diff --git a/flake.nix b/flake.nix index 2bbfd5c833f8..14b3defd5e4e 100644 --- a/flake.nix +++ b/flake.nix @@ -4,13 +4,9 @@ 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 }: + outputs = { self, nixpkgs }: let system = "x86_64-linux"; pkgs = nixpkgs.legacyPackages.${system}; @@ -44,8 +40,6 @@ 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 ''; From 58ca8d397089df4c3969642480d98b1e2f6afba6 Mon Sep 17 00:00:00 2001 From: Souheab Date: Thu, 18 Jun 2026 18:41:58 -0400 Subject: [PATCH 2/5] Update vendor hash Signed-off-by: Souheab --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 14b3defd5e4e..915c1028ab6d 100644 --- a/flake.nix +++ b/flake.nix @@ -17,7 +17,7 @@ src = ./.; proxyVendor = true; - vendorHash = "sha256-6f3adjGsoFXlUtXjBDHP4Mv9jKCOK3aeUXprm0EAVO8="; + vendorHash = "sha256-z3lxQS8mXFuJzvYamejwapwVEmLpeAoiO3ksUKb4I3Q="; nativeBuildInputs = with pkgs; [ pkg-config cmake gcc protobuf go-protobuf protoc-gen-go protoc-gen-go-grpc From b26cf82e751bc96f98f71835c9ca98543b69a82f Mon Sep 17 00:00:00 2001 From: Souheab Date: Thu, 18 Jun 2026 18:43:06 -0400 Subject: [PATCH 3/5] Create react-ui derivation as it is required for go build Signed-off-by: Souheab --- flake.nix | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/flake.nix b/flake.nix index 915c1028ab6d..2d18ff4da371 100644 --- a/flake.nix +++ b/flake.nix @@ -10,6 +10,20 @@ let system = "x86_64-linux"; pkgs = nixpkgs.legacyPackages.${system}; + reactUi = pkgs.buildNpmPackage { + pname = "localai-react-ui"; + version = "custom"; + src = ./core/http/react-ui; + npmDepsHash = "sha256-G+bc1SajltRt4ZfkKNN1h6kFSmD0pCOR8MqRE6cKDLM="; + npmBuildScript = "build"; + + installPhase = '' + runHook preInstall + mkdir -p $out + cp -r dist $out/ + runHook postInstall + ''; + }; in { packages.${system}.default = pkgs.buildGoModule { pname = "localai"; @@ -40,6 +54,9 @@ go mod edit -replace github.com/mudler/LocalAI/pkg/grpc/proto=./pkg/grpc/proto + mkdir -p core/http/react-ui + cp -r ${reactUi}/dist core/http/react-ui/dist + sed -i '/go:generate/d' core/config/inference_defaults.go || true ''; From fa083969189c9470480e1b72ca378b742b0f1a2c Mon Sep 17 00:00:00 2001 From: Souheab Date: Thu, 18 Jun 2026 19:54:06 -0400 Subject: [PATCH 4/5] Add FHS env wrapper to make #!/bin/bash scripts work Signed-off-by: Souheab --- flake.nix | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/flake.nix b/flake.nix index 2d18ff4da371..44dbc14206bd 100644 --- a/flake.nix +++ b/flake.nix @@ -24,8 +24,7 @@ runHook postInstall ''; }; - in { - packages.${system}.default = pkgs.buildGoModule { + localai-unwrapped = pkgs.buildGoModule { pname = "localai"; version = "custom"; @@ -68,6 +67,21 @@ [ -f $out/bin/local-ai ] && mv $out/bin/local-ai $out/bin/localai ''; }; + in { + packages.${system} = { + localai-unwrapped = localai-unwrapped; + + default = pkgs.buildFHSEnv { + name = "localai"; + targetPkgs = pkgs: with pkgs; [ + localai-unwrapped + bash + coreutils + gnugrep + ]; + runScript = "${localai-unwrapped}/bin/localai"; + }; + }; devShells.${system}.default = pkgs.mkShell { packages = with pkgs; [ From d8f968cca402ee082ede743099cca97dd3a2ce43 Mon Sep 17 00:00:00 2001 From: Souheab Date: Fri, 19 Jun 2026 00:41:38 -0400 Subject: [PATCH 5/5] use pkgs.importNpmLock to deal with npm dependencies instead of using npmDepsHash Signed-off-by: Souheab --- flake.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 44dbc14206bd..89691c716b7f 100644 --- a/flake.nix +++ b/flake.nix @@ -14,7 +14,10 @@ pname = "localai-react-ui"; version = "custom"; src = ./core/http/react-ui; - npmDepsHash = "sha256-G+bc1SajltRt4ZfkKNN1h6kFSmD0pCOR8MqRE6cKDLM="; + npmDeps = pkgs.importNpmLock { + npmRoot = ./core/http/react-ui; + }; + npmConfigHook = pkgs.importNpmLock.npmConfigHook; npmBuildScript = "build"; installPhase = ''