-
Notifications
You must be signed in to change notification settings - Fork 102
Expand file tree
/
Copy pathpackage.nix
More file actions
95 lines (83 loc) · 2.24 KB
/
package.nix
File metadata and controls
95 lines (83 loc) · 2.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
{
lib,
rustPlatform,
fetchFromGitHub,
pkg-config,
openssl,
onnxruntime,
libGL,
libxkbcommon,
wayland,
libx11,
libxcursor,
libxi,
libxrandr,
versionCheckHook,
versionCheckHomeHook,
}:
rustPlatform.buildRustPackage rec {
pname = "localgpt";
version = "0.3.5";
src = fetchFromGitHub {
owner = "localgpt-app";
repo = "localgpt";
tag = "v${version}";
hash = "sha256-9csMVyoDaOzOrQyK+tV4OGKTiqMrfJ8eZTjS0iF3iio=";
};
cargoHash = "sha256-yua5JiG96t6kTnu2fq61B5zl33x3keNU2LWTJeByn0I=";
# Disable slow LTO and single codegen-unit for faster Nix builds.
# Use system openssl instead of vendored (which needs perl to build from source).
postPatch = ''
substituteInPlace Cargo.toml \
--replace-fail 'lto = true' 'lto = false' \
--replace-fail 'codegen-units = 1' "" \
--replace-fail 'native-tls-vendored' 'native-tls'
'';
nativeBuildInputs = [ pkg-config ];
buildInputs = [
openssl
onnxruntime
# eframe/glow compile-time deps (desktop feature is default)
libGL
libxkbcommon
wayland
libx11
libxcursor
libxi
libxrandr
];
env = {
# Use system onnxruntime instead of downloading binaries
ORT_LIB_LOCATION = "${lib.getLib onnxruntime}/lib";
ORT_PREFER_DYNAMIC_LINK = "1";
};
# Add runtime library paths for dlopen'd libs (onnxruntime, GL, wayland, xkbcommon)
postFixup = ''
patchelf --add-rpath "${
lib.makeLibraryPath [
onnxruntime
libGL
libxkbcommon
wayland
]
}" $out/bin/localgpt
'';
# Tests require network access and writable directories
doCheck = false;
doInstallCheck = true;
nativeInstallCheckInputs = [
versionCheckHook
versionCheckHomeHook
];
passthru.category = "AI Assistants";
meta = with lib; {
description = "Local AI assistant with persistent markdown memory, autonomous tasks, and semantic search";
homepage = "https://github.com/localgpt-app/localgpt";
changelog = "https://github.com/localgpt-app/localgpt/releases/tag/v${version}";
license = licenses.asl20;
sourceProvenance = with sourceTypes; [ fromSource ];
# onnxruntime rpath linking is broken on Darwin
platforms = platforms.linux;
mainProgram = "localgpt";
};
}