Skip to content

Commit 59c7ad5

Browse files
authored
fix(nix flake): ensure nix flake builds successfully (#10399)
* 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 <souheab@protonmail.com> * Update vendor hash Signed-off-by: Souheab <souheab@protonmail.com> * Create react-ui derivation as it is required for go build Signed-off-by: Souheab <souheab@protonmail.com> * Add FHS env wrapper to make #!/bin/bash scripts work Signed-off-by: Souheab <souheab@protonmail.com> * use pkgs.importNpmLock to deal with npm dependencies instead of using npmDepsHash Signed-off-by: Souheab <souheab@protonmail.com> --------- Signed-off-by: Souheab <souheab@protonmail.com>
1 parent 78d6822 commit 59c7ad5

2 files changed

Lines changed: 38 additions & 23 deletions

File tree

flake.lock

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

flake.nix

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,36 @@
44

55
inputs = {
66
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-
};
117
};
128

13-
outputs = { self, nixpkgs, inference-defaults }:
9+
outputs = { self, nixpkgs }:
1410
let
1511
system = "x86_64-linux";
1612
pkgs = nixpkgs.legacyPackages.${system};
17-
in {
18-
packages.${system}.default = pkgs.buildGoModule {
13+
reactUi = pkgs.buildNpmPackage {
14+
pname = "localai-react-ui";
15+
version = "custom";
16+
src = ./core/http/react-ui;
17+
npmDeps = pkgs.importNpmLock {
18+
npmRoot = ./core/http/react-ui;
19+
};
20+
npmConfigHook = pkgs.importNpmLock.npmConfigHook;
21+
npmBuildScript = "build";
22+
23+
installPhase = ''
24+
runHook preInstall
25+
mkdir -p $out
26+
cp -r dist $out/
27+
runHook postInstall
28+
'';
29+
};
30+
localai-unwrapped = pkgs.buildGoModule {
1931
pname = "localai";
2032
version = "custom";
2133

2234
src = ./.;
2335
proxyVendor = true;
24-
vendorHash = "sha256-6f3adjGsoFXlUtXjBDHP4Mv9jKCOK3aeUXprm0EAVO8=";
36+
vendorHash = "sha256-z3lxQS8mXFuJzvYamejwapwVEmLpeAoiO3ksUKb4I3Q=";
2537

2638
nativeBuildInputs = with pkgs; [
2739
pkg-config cmake gcc protobuf go-protobuf protoc-gen-go protoc-gen-go-grpc
@@ -44,8 +56,9 @@
4456
4557
go mod edit -replace github.com/mudler/LocalAI/pkg/grpc/proto=./pkg/grpc/proto
4658
47-
mkdir -p core/config/gen_inference_defaults
48-
cp ${inference-defaults} core/config/gen_inference_defaults/inference_defaults.json
59+
mkdir -p core/http/react-ui
60+
cp -r ${reactUi}/dist core/http/react-ui/dist
61+
4962
sed -i '/go:generate/d' core/config/inference_defaults.go || true
5063
5164
'';
@@ -57,6 +70,21 @@
5770
[ -f $out/bin/local-ai ] && mv $out/bin/local-ai $out/bin/localai
5871
'';
5972
};
73+
in {
74+
packages.${system} = {
75+
localai-unwrapped = localai-unwrapped;
76+
77+
default = pkgs.buildFHSEnv {
78+
name = "localai";
79+
targetPkgs = pkgs: with pkgs; [
80+
localai-unwrapped
81+
bash
82+
coreutils
83+
gnugrep
84+
];
85+
runScript = "${localai-unwrapped}/bin/localai";
86+
};
87+
};
6088

6189
devShells.${system}.default = pkgs.mkShell {
6290
packages = with pkgs; [

0 commit comments

Comments
 (0)