2024-02-07 01:22:34 +00:00
|
|
|
{ lib
|
2024-06-05 15:53:02 +00:00
|
|
|
, config
|
2024-02-07 01:22:34 +00:00
|
|
|
, stdenv
|
|
|
|
, fetchFromGitHub
|
2024-09-19 14:19:46 +00:00
|
|
|
, fetchurl
|
2024-02-07 01:22:34 +00:00
|
|
|
, cmake
|
|
|
|
, qt6
|
|
|
|
, fmt
|
|
|
|
, shaderc
|
|
|
|
, vulkan-headers
|
|
|
|
, wayland
|
2024-06-05 15:53:02 +00:00
|
|
|
, cudaSupport ? config.cudaSupport
|
|
|
|
, cudaPackages ? { }
|
2024-09-19 14:19:46 +00:00
|
|
|
, autoAddDriverRunpath
|
2024-02-07 01:22:34 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
stdenv.mkDerivation (finalAttrs: {
|
2024-02-29 20:09:43 +00:00
|
|
|
pname = "gpt4all";
|
2024-09-19 14:19:46 +00:00
|
|
|
version = "3.2.1";
|
2024-02-07 01:22:34 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
fetchSubmodules = true;
|
2024-09-19 14:19:46 +00:00
|
|
|
hash = "sha256-h6hcqafTjQsqVlpnqVeohh38A67VSGrW3WrCErjaKIQ=";
|
2024-02-07 01:22:34 +00:00
|
|
|
owner = "nomic-ai";
|
|
|
|
repo = "gpt4all";
|
|
|
|
rev = "v${finalAttrs.version}";
|
|
|
|
};
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
embed_model = fetchurl {
|
|
|
|
url = "https://gpt4all.io/models/gguf/nomic-embed-text-v1.5.f16.gguf";
|
|
|
|
hash = "sha256-969vZoAvTfhu2hD+m7z8dcOVYr7Ujvas5xmiUc8cL9s=";
|
|
|
|
};
|
|
|
|
|
|
|
|
patches = [
|
|
|
|
./embedding-local.patch
|
|
|
|
];
|
|
|
|
|
2024-02-07 01:22:34 +00:00
|
|
|
sourceRoot = "${finalAttrs.src.name}/gpt4all-chat";
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
cmake
|
|
|
|
qt6.wrapQtAppsHook
|
2024-06-05 15:53:02 +00:00
|
|
|
] ++ lib.optionals cudaSupport [
|
|
|
|
cudaPackages.cuda_nvcc
|
2024-09-19 14:19:46 +00:00
|
|
|
autoAddDriverRunpath
|
2024-02-07 01:22:34 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
buildInputs = [
|
|
|
|
fmt
|
|
|
|
qt6.qtwayland
|
|
|
|
qt6.qtquicktimeline
|
|
|
|
qt6.qtsvg
|
|
|
|
qt6.qthttpserver
|
|
|
|
qt6.qtwebengine
|
|
|
|
qt6.qt5compat
|
2024-09-19 14:19:46 +00:00
|
|
|
qt6.qttools
|
2024-02-07 01:22:34 +00:00
|
|
|
shaderc
|
|
|
|
vulkan-headers
|
|
|
|
wayland
|
2024-06-05 15:53:02 +00:00
|
|
|
] ++ lib.optionals cudaSupport (
|
2024-09-19 14:19:46 +00:00
|
|
|
with cudaPackages;
|
|
|
|
[
|
|
|
|
cuda_cccl
|
|
|
|
cuda_cudart
|
|
|
|
libcublas
|
|
|
|
]
|
|
|
|
);
|
2024-02-07 01:22:34 +00:00
|
|
|
|
|
|
|
cmakeFlags = [
|
|
|
|
"-DKOMPUTE_OPT_USE_BUILT_IN_VULKAN_HEADER=OFF"
|
|
|
|
"-DKOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK=ON"
|
|
|
|
"-DKOMPUTE_OPT_USE_BUILT_IN_FMT=OFF"
|
2024-06-05 15:53:02 +00:00
|
|
|
] ++ lib.optionals (!cudaSupport) [
|
|
|
|
"-DLLMODEL_CUDA=OFF"
|
2024-02-07 01:22:34 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
postInstall = ''
|
|
|
|
rm -rf $out/include
|
|
|
|
rm -rf $out/lib/*.a
|
|
|
|
mv $out/bin/chat $out/bin/${finalAttrs.meta.mainProgram}
|
2024-09-19 14:19:46 +00:00
|
|
|
install -D ${finalAttrs.embed_model} $out/resources/nomic-embed-text-v1.5.f16.gguf
|
2024-02-07 01:22:34 +00:00
|
|
|
install -m 444 -D $src/gpt4all-chat/flatpak-manifest/io.gpt4all.gpt4all.desktop $out/share/applications/io.gpt4all.gpt4all.desktop
|
2024-09-19 14:19:46 +00:00
|
|
|
install -m 444 -D $src/gpt4all-chat/icons/nomic_logo.svg $out/share/icons/hicolor/scalable/apps/io.gpt4all.gpt4all.svg
|
2024-02-07 01:22:34 +00:00
|
|
|
substituteInPlace $out/share/applications/io.gpt4all.gpt4all.desktop \
|
2024-04-21 15:54:59 +00:00
|
|
|
--replace-fail 'Exec=chat' 'Exec=${finalAttrs.meta.mainProgram}'
|
2024-02-07 01:22:34 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
meta = {
|
2024-02-29 20:09:43 +00:00
|
|
|
changelog = "https://github.com/nomic-ai/gpt4all/releases/tag/v${finalAttrs.version}";
|
2024-06-20 14:57:18 +00:00
|
|
|
description = "Free-to-use, locally running, privacy-aware chatbot. No GPU or internet required";
|
2024-02-29 20:09:43 +00:00
|
|
|
homepage = "https://github.com/nomic-ai/gpt4all";
|
2024-02-07 01:22:34 +00:00
|
|
|
license = lib.licenses.mit;
|
2024-02-29 20:09:43 +00:00
|
|
|
mainProgram = "gpt4all";
|
2024-09-19 14:19:46 +00:00
|
|
|
maintainers = with lib.maintainers; [ polygon titaniumtown ];
|
2024-02-07 01:22:34 +00:00
|
|
|
};
|
|
|
|
})
|