Merge release-23.11 into staging-next-23.11

This commit is contained in:
github-actions[bot]
2024-03-06 00:13:16 +00:00
committed by GitHub
22 changed files with 719 additions and 505 deletions

View File

@@ -362,6 +362,13 @@
githubId = 2526296;
name = "Adrien Bustany";
};
abysssol = {
name = "abysssol";
email = "abysssol@pm.me";
matrix = "@abysssol:tchncs.de";
github = "abysssol";
githubId = 76763323;
};
acairncross = {
email = "acairncross@gmail.com";
github = "acairncross";

View File

@@ -711,6 +711,7 @@
./services/misc/nzbget.nix
./services/misc/nzbhydra2.nix
./services/misc/octoprint.nix
./services/misc/ollama.nix
./services/misc/ombi.nix
./services/misc/osrm.nix
./services/misc/owncast.nix

View File

@@ -0,0 +1,65 @@
{ config, lib, pkgs, ... }:
let
inherit (lib) types;
cfg = config.services.ollama;
ollamaPackage = cfg.package.override {
inherit (cfg) acceleration;
linuxPackages = config.boot.kernelPackages // {
nvidia_x11 = config.hardware.nvidia.package;
};
};
in
{
options = {
services.ollama = {
enable = lib.mkEnableOption (
lib.mdDoc "Server for local large language models"
);
listenAddress = lib.mkOption {
type = types.str;
default = "127.0.0.1:11434";
description = lib.mdDoc ''
Specifies the bind address on which the ollama server HTTP interface listens.
'';
};
acceleration = lib.mkOption {
type = types.nullOr (types.enum [ "rocm" "cuda" ]);
default = null;
example = "rocm";
description = lib.mdDoc ''
Specifies the interface to use for hardware acceleration.
- `rocm`: supported by modern AMD GPUs
- `cuda`: supported by modern NVIDIA GPUs
'';
};
package = lib.mkPackageOption pkgs "ollama" { };
};
};
config = lib.mkIf cfg.enable {
systemd = {
services.ollama = {
wantedBy = [ "multi-user.target" ];
description = "Server for local large language models";
after = [ "network.target" ];
environment = {
HOME = "%S/ollama";
OLLAMA_MODELS = "%S/ollama/models";
OLLAMA_HOST = cfg.listenAddress;
};
serviceConfig = {
ExecStart = "${lib.getExe ollamaPackage} serve";
WorkingDirectory = "/var/lib/ollama";
StateDirectory = [ "ollama" ];
DynamicUser = true;
};
};
};
environment.systemPackages = [ ollamaPackage ];
};
meta.maintainers = with lib.maintainers; [ abysssol onny ];
}

View File

@@ -6,6 +6,7 @@
, SDL_image
, SDL_ttf
, gtk3
, wrapGAppsHook
}:
stdenv.mkDerivation rec {
@@ -21,6 +22,7 @@ stdenv.mkDerivation rec {
nativeBuildInputs = [
pkg-config
wrapGAppsHook
];
buildInputs = [
@@ -62,6 +64,7 @@ stdenv.mkDerivation rec {
'';
license = licenses.bsd3;
platforms = platforms.all;
mainProgram = "hivelytracker";
maintainers = with maintainers; [ fgaz ];
broken = stdenv.isDarwin; # TODO: try to use xcbuild
};

View File

@@ -3,10 +3,10 @@
{
firefox = buildMozillaMach rec {
pname = "firefox";
version = "123.0";
version = "123.0.1";
src = fetchurl {
url = "mirror://mozilla/firefox/releases/${version}/source/firefox-${version}.source.tar.xz";
sha512 = "a19567a13e1b663e538c4af17491146adad1f0ab977995e8da9ce9ed428008ad20902dee4efb82d54e1319a0e31768609696bc822563d75732b622760129d8bb";
sha512 = "e9af61c1ca800edd16ab7a0d24c9a36bbb34813ed0a11ff62389aa38fa83deba394bca5d95cdaad55ad29ffa3c0e5d3dd15ac1099f7fa3649f4b6c835b7498c2";
};
extraPatches = [

View File

@@ -6,11 +6,11 @@
stdenvNoCC.mkDerivation (finalAttrs: {
pname = "rectangle-pro";
version = "3.0.11";
version = "3.0.19";
src = fetchurl {
url = "https://rectangleapp.com/pro/downloads/Rectangle%20Pro%20${finalAttrs.version}.dmg";
hash = "sha256-Hs2eRO5DpYoY0rLfcmGZRHjmg+wddz/+LE0u4E9gCTk=";
hash = "sha256-ZWIjxaxV90I42Stg7jFUItJBZLoXm8iLIeQzcssRQLA=";
};
sourceRoot = ".";

View File

@@ -7,10 +7,10 @@
inherit buildUnstable;
}).overrideAttrs (finalAttrs: _: {
pname = "renode-unstable";
version = "1.14.0+20240226git732d357b4";
version = "1.14.0+20240305gitcec51e561";
src = fetchurl {
url = "https://builds.renode.io/renode-${finalAttrs.version}.linux-portable.tar.gz";
hash = "sha256-08xV/6ch6dWA4pwg8tuDywYhQ4ZIFRD5zegojDZtAHE=";
hash = "sha256-dXT4C/s7Aygqhq0U6MiPsQL8ZvjPfTzKYuhA6aRQKlI=";
};
})

View File

@@ -6,11 +6,11 @@
stdenvNoCC.mkDerivation (finalAttrs: {
pname = "stats";
version = "2.9.11";
version = "2.10.3";
src = fetchurl {
url = "https://github.com/exelban/stats/releases/download/v${finalAttrs.version}/Stats.dmg";
hash = "sha256-L7E3naVeFYxeS8OAEkXEgY7YB+6E+yrGfIAUr52EWvA=";
hash = "sha256-PSRK9YihiIHKHade3XE/OnAleBhmu71CNFyzJ/Upx/A=";
};
sourceRoot = ".";

View File

@@ -15,14 +15,14 @@
buildPythonPackage rec {
pname = "django";
version = "3.2.24";
version = "3.2.25";
disabled = pythonOlder "3.7";
src = fetchPypi {
pname = "Django";
inherit version;
hash = "sha256-qu6fsPtOvUMRUgiHrS4zMT02iEZgf4KpoO1GHNTDWxg=";
hash = "sha256-fKOKeGVK7nI3hZTWPlFjbAS44oV09VBd/2MIlbVHJ3c=";
};
patches = [

View File

@@ -15,7 +15,7 @@
buildPythonPackage rec {
pname = "nbxmpp";
version = "4.5.3";
version = "4.5.4";
format = "pyproject";
disabled = pythonOlder "3.10";
@@ -25,7 +25,7 @@ buildPythonPackage rec {
owner = "gajim";
repo = "python-nbxmpp";
rev = "refs/tags/${version}";
hash = "sha256-vAuHfG2/DVUDCxUb7UMRejIh4fQHGl67A+dncvcJ8jQ=";
hash = "sha256-n5Pzw8aikzCml+dOhkLoHR0ytFkEb4AYpw/bIpo6Wd4=";
};
nativeBuildInputs = [

View File

@@ -94,23 +94,23 @@ rec {
# we have to keep all the numbers in the version to handle major/minor/patch level.
# for <1.0.
garage_0_8_6 = generic {
version = "0.8.6";
sha256 = "sha256-N0AOcwpuBHwTZtHcz6a2d9GOimHevhohEOzVkIt0RDE=";
cargoSha256 = "sha256-e72FQKL77CZOi/pa+hE7PCyc1+HSJgEsKGgWlfVw51k=";
garage_0_8_7 = generic {
version = "0.8.7";
sha256 = "sha256-2QGbR6YvMQeMxN3n1MMJ5qfBcEJ5hjXARUOfEn+m4Jc=";
cargoSha256 = "sha256-Q0QyBNPEDrlhgIHD4q7Qb1Pu3xBvzlLOSW7LSWWdoIo=";
broken = stdenv.isDarwin;
};
garage_0_8 = garage_0_8_6;
garage_0_8 = garage_0_8_7;
garage_0_9_2 = generic {
version = "0.9.2";
sha256 = "sha256-6a400/wOZunVH+LAByd6BEA0gs56Rxyh+gvM4hUO4Y8=";
cargoSha256 = "sha256-1p6bB2gMOCHDdILEwgoJ1EqvgGhLPcThNkwaz6NMZhQ=";
garage_0_9_3 = generic {
version = "0.9.3";
sha256 = "sha256-NN2HoheSW2+SAFX71K12KTe0wpaBEwkwxvZDi0Bdx+8=";
cargoSha256 = "sha256-OabgWVMkccFFAtBHEf3z+MRVcWaO+NCk/pumEqdNNRs=";
broken = stdenv.isDarwin;
};
garage_0_9 = garage_0_9_2;
garage_0_9 = garage_0_9_3;
garage = garage_0_9;
}

View File

@@ -0,0 +1,7 @@
--- a/llm/llama.cpp/examples/server/CMakeLists.txt
+++ b/llm/llama.cpp/examples/server/CMakeLists.txt
@@ -11,3 +11,4 @@
TARGET_LINK_LIBRARIES(${TARGET} PRIVATE ws2_32)
endif()
target_compile_features(${TARGET} PRIVATE cxx_std_11)
+include (../../../ext_server/CMakeLists.txt) # ollama

View File

@@ -1,36 +1,167 @@
{ lib
, buildGoModule
, fetchFromGitHub
, llama-cpp
, fetchpatch
, buildEnv
, linkFarm
, overrideCC
, makeWrapper
, stdenv
, pkgs
, cmake
, gcc11
, clblast
, libdrm
, rocmPackages
, cudaPackages
, linuxPackages
, darwin
# one of `[ null "rocm" "cuda" ]`
, acceleration ? null
}:
buildGoModule rec {
let
pname = "ollama";
version = "0.1.7";
version = "0.1.27";
src = fetchFromGitHub {
owner = "jmorganca";
repo = "ollama";
rev = "v${version}";
hash = "sha256-rzcuRU2qcYTMo/GxiSHwJYnvA9samfWlztMEhOGzbRg=";
hash = "sha256-+ayby+yVknFHLTyLjMAPMnOTMSzTKqzi9caN/TppcEg=";
fetchSubmodules = true;
};
patches = [
# disable passing the deprecated gqa flag to llama-cpp-server
# see https://github.com/ggerganov/llama.cpp/issues/2975
./disable-gqa.patch
validAccel = lib.assertOneOf "ollama.acceleration" acceleration [ null "rocm" "cuda" ];
# replace the call to the bundled llama-cpp-server with the one in the llama-cpp package
./set-llamacpp-path.patch
warnIfNotLinux = api: (lib.warnIfNot stdenv.isLinux
"building ollama with `${api}` is only supported on linux; falling back to cpu"
stdenv.isLinux);
enableRocm = validAccel && (acceleration == "rocm") && (warnIfNotLinux "rocm");
enableCuda = validAccel && (acceleration == "cuda") && (warnIfNotLinux "cuda");
rocmClang = linkFarm "rocm-clang" {
llvm = rocmPackages.llvm.clang;
};
rocmPath = buildEnv {
name = "rocm-path";
paths = [
rocmPackages.rocm-device-libs
rocmClang
];
};
cudaToolkit = buildEnv {
name = "cuda-toolkit";
ignoreCollisions = true; # FIXME: find a cleaner way to do this without ignoring collisions
paths = [
cudaPackages.cudatoolkit
cudaPackages.cuda_cudart
];
postBuild = ''
rm "$out/lib64"
ln -s "lib" "$out/lib64"
ln -s "stubs/libcuda.so" "$out/lib/libcuda.so"
ln -s "stubs/libcuda.so" "$out/lib/libcuda.so.1"
'';
};
runtimeLibs = lib.optionals enableRocm [
rocmPackages.rocm-smi
] ++ lib.optionals enableCuda [
linuxPackages.nvidia_x11
];
postPatch = ''
substituteInPlace llm/llama.go \
--subst-var-by llamaCppServer "${llama-cpp}/bin/llama-cpp-server"
'';
appleFrameworks = darwin.apple_sdk_11_0.frameworks;
metalFrameworks = [
appleFrameworks.Accelerate
appleFrameworks.Metal
appleFrameworks.MetalKit
appleFrameworks.MetalPerformanceShaders
];
vendorHash = "sha256-Qt5QVqRkwK61BJPVhFWtox6b9E8BpAIseNB0yhh+/90=";
goBuild =
if enableCuda then
buildGoModule.override { stdenv = overrideCC stdenv gcc11; }
else
buildGoModule;
preparePatch = patch: hash: fetchpatch {
url = "file://${src}/llm/patches/${patch}";
inherit hash;
stripLen = 1;
extraPrefix = "llm/llama.cpp/";
};
inherit (lib) licenses platforms maintainers;
in
goBuild ((lib.optionalAttrs enableRocm {
ROCM_PATH = rocmPath;
CLBlast_DIR = "${clblast}/lib/cmake/CLBlast";
}) // (lib.optionalAttrs enableCuda {
CUDA_LIB_DIR = "${cudaToolkit}/lib";
CUDACXX = "${cudaToolkit}/bin/nvcc";
CUDAToolkit_ROOT = cudaToolkit;
}) // {
inherit pname version src;
vendorHash = "sha256-zTrBighPBqZ9hhkEV3UawJZUYyPRay7+P6wkhDtpY7M=";
nativeBuildInputs = [
cmake
] ++ lib.optionals (enableRocm || enableCuda) [
makeWrapper
] ++ lib.optionals stdenv.isDarwin
metalFrameworks;
buildInputs = lib.optionals enableRocm [
rocmPackages.clr
rocmPackages.hipblas
rocmPackages.rocblas
rocmPackages.rocsolver
rocmPackages.rocsparse
libdrm
] ++ lib.optionals enableCuda [
cudaPackages.cuda_cudart
] ++ lib.optionals stdenv.isDarwin
metalFrameworks;
patches = [
# remove uses of `git` in the `go generate` script
# instead use `patch` where necessary
./remove-git.patch
# replace a hardcoded use of `g++` with `$CXX`
./replace-gcc.patch
# ollama's patches of llama.cpp's example server
# `ollama/llm/generate/gen_common.sh` -> "apply temporary patches until fix is upstream"
(preparePatch "01-cache.diff" "sha256-MTTln2G0G8dntihUzEjPM1ruTsApb4ZToBczJb8EG68=")
(preparePatch "02-cudaleaks.diff" "sha256-Cu7E9iEcvddPL9mPPI5Z96qmwWigi3f0WgSpPRjGc88=")
];
postPatch = ''
# use a patch from the nix store in the `go generate` script
substituteInPlace llm/generate/gen_common.sh \
--subst-var-by cmakeIncludePatch '${./cmake-include.patch}'
# `ollama/llm/generate/gen_common.sh` -> "avoid duplicate main symbols when we link into the cgo binary"
substituteInPlace llm/llama.cpp/examples/server/server.cpp \
--replace 'int main(' 'int __main('
# replace inaccurate version number with actual release version
substituteInPlace version/version.go --replace 0.0.0 '${version}'
'';
preBuild = ''
export OLLAMA_SKIP_PATCHING=true
# build llama.cpp libraries for ollama
go generate ./...
'';
postFixup = ''
# the app doesn't appear functional at the moment, so hide it
mv "$out/bin/app" "$out/bin/.ollama-app"
'' + lib.optionalString (enableRocm || enableCuda) ''
# expose runtime libraries necessary to use the gpu
mv "$out/bin/ollama" "$out/bin/.ollama-unwrapped"
makeWrapper "$out/bin/.ollama-unwrapped" "$out/bin/ollama" \
--suffix LD_LIBRARY_PATH : '/run/opengl-driver/lib:${lib.makeLibraryPath runtimeLibs}'
'';
ldflags = [
"-s"
@@ -39,12 +170,18 @@ buildGoModule rec {
"-X=github.com/jmorganca/ollama/server.mode=release"
];
meta = with lib; {
# for now, just test that rocm and cuda build
passthru.tests = lib.optionalAttrs stdenv.isLinux {
rocm = pkgs.ollama.override { acceleration = "rocm"; };
cuda = pkgs.ollama.override { acceleration = "cuda"; };
};
meta = {
description = "Get up and running with large language models locally";
homepage = "https://github.com/jmorganca/ollama";
license = licenses.mit;
mainProgram = "ollama";
maintainers = with maintainers; [ dit7ya elohmeier ];
platforms = platforms.unix;
mainProgram = "ollama";
maintainers = with maintainers; [ abysssol dit7ya elohmeier ];
};
}
})

View File

@@ -1,15 +0,0 @@
diff --git a/llm/llama.go b/llm/llama.go
index 0b460e9..b79e04a 100644
--- a/llm/llama.go
+++ b/llm/llama.go
@@ -299,10 +299,6 @@ func newLlama(model string, adapters []string, runners []ModelRunner, numLayers
params = append(params, "--n-gpu-layers", fmt.Sprintf("%d", numGPU))
}
- if opts.NumGQA > 0 {
- params = append(params, "--gqa", fmt.Sprintf("%d", opts.NumGQA))
- }
-
if len(adapters) > 0 {
// TODO: applying multiple adapters is not supported by the llama.cpp server yet
params = append(params, "--lora", adapters[0])

View File

@@ -0,0 +1,21 @@
--- a/llm/generate/gen_common.sh
+++ b/llm/generate/gen_common.sh
@@ -60,6 +60,9 @@
}
apply_patches() {
+ patch -i '@cmakeIncludePatch@' "${LLAMACPP_DIR}/examples/server/CMakeLists.txt"
+ return
+
# Wire up our CMakefile
if ! grep ollama ${LLAMACPP_DIR}/examples/server/CMakeLists.txt; then
echo 'include (../../../ext_server/CMakeLists.txt) # ollama' >>${LLAMACPP_DIR}/examples/server/CMakeLists.txt
@@ -113,6 +116,8 @@
# Keep the local tree clean after we're done with the build
cleanup() {
+ return
+
(cd ${LLAMACPP_DIR}/examples/server/ && git checkout CMakeLists.txt server.cpp)
if [ -n "$(ls -A ../patches/*.diff)" ]; then

View File

@@ -0,0 +1,11 @@
--- a/llm/generate/gen_common.sh
+++ b/llm/generate/gen_common.sh
@@ -86,7 +89,7 @@
cmake -S ${LLAMACPP_DIR} -B ${BUILD_DIR} ${CMAKE_DEFS}
cmake --build ${BUILD_DIR} ${CMAKE_TARGETS} -j8
mkdir -p ${BUILD_DIR}/lib/
- g++ -fPIC -g -shared -o ${BUILD_DIR}/lib/libext_server.${LIB_EXT} \
+ $CXX -fPIC -g -shared -o ${BUILD_DIR}/lib/libext_server.${LIB_EXT} \
${GCC_ARCH} \
${WHOLE_ARCHIVE} ${BUILD_DIR}/examples/server/libext_server.a ${NO_WHOLE_ARCHIVE} \
${BUILD_DIR}/common/libcommon.a \

View File

@@ -1,23 +0,0 @@
diff --git a/llm/llama.go b/llm/llama.go
index f23d5d8..6563550 100644
--- a/llm/llama.go
+++ b/llm/llama.go
@@ -25,7 +25,6 @@ import (
"github.com/jmorganca/ollama/api"
)
-//go:embed llama.cpp/*/build/*/bin/*
var llamaCppEmbed embed.FS
type ModelRunner struct {
@@ -33,6 +32,10 @@ type ModelRunner struct {
}
func chooseRunners(workDir, runnerType string) []ModelRunner {
+ return []ModelRunner{
+ {Path: "@llamaCppServer@"},
+ }
+
buildPath := path.Join("llama.cpp", runnerType, "build")
var runners []string

View File

@@ -2,13 +2,13 @@
buildGoModule rec {
pname = "goimapnotify";
version = "2.3.9";
version = "2.3.11";
src = fetchFromGitLab {
owner = "shackra";
repo = "goimapnotify";
rev = version;
sha256 = "sha256-BsoLoCOP6B9WaLBFF/1esPOj+0Rz0jkDJ8XjzirsCoU=";
sha256 = "sha256-b3w+SqmxRY/24qgFUSM4RQswObAH5jy3yEfGXY298Ko=";
};
vendorHash = "sha256-DphGe9jbKo1aIfpF5kRYNSn/uIYHaRMrygda5t46svw=";

View File

@@ -368,20 +368,20 @@ std::string describeError(const Error & e) { return "«error: " + e.msg() + "»"
void describeDerivation(Context & ctx, Out & out, Value v)
{
// Copy-pasted from nix/src/nix/repl.cc :(
out << "«derivation ";
Bindings::iterator i = v.attrs->find(ctx.state.sDrvPath);
PathSet pathset;
try {
Path drvPath = i != v.attrs->end() ? ctx.state.coerceToPath(i->pos, *i->value, pathset, "while evaluating the drvPath of a derivation") : "???";
out << "«derivation " << drvPath << "»";
} catch (Error & e) {
out << describeError(e);
}
nix::NixStringContext strContext;
if (i != v.attrs->end())
out << ctx.state.store->printStorePath(ctx.state.coerceToStorePath(i->pos, *i->value, strContext, "while evaluating the drvPath of a derivation"));
else
out << "???";
out << "»";
}
Value parseAndEval(EvalState & state, const std::string & expression, const std::string & path)
{
Value v{};
state.eval(state.parseExprFromString(expression, absPath(path)), v);
state.eval(state.parseExprFromString(expression, nix::SourcePath(nix::CanonPath::fromCwd(path))), v);
return v;
}

View File

@@ -8,16 +8,16 @@
rustPlatform.buildRustPackage {
pname = "deploy-rs";
version = "unstable-2023-12-20";
version = "unstable-2024-02-16";
src = fetchFromGitHub {
owner = "serokell";
repo = "deploy-rs";
rev = "b709d63debafce9f5645a5ba550c9e0983b3d1f7";
hash = "sha256-0VUbWBW8VyiDRuimMuLsEO4elGuUw/nc2WDeuO1eN1M=";
rev = "0a0187794ac7f7a1e62cda3dabf8dc041f868790";
hash = "sha256-dTGGw2y8wvfjr+J9CjQbfdulOq72hUG17HXVNxpH1yE=";
};
cargoHash = "sha256-PVeCB1g3JSYE6PKWHyE3hfN/CKlb9XErt8uaD/ZyxIs=";
cargoHash = "sha256-Vo/45cZM/sBAaoikhEwCvduhMQjurwSZwCjwrIQn7IA=";
buildInputs = lib.optionals stdenv.isDarwin [
CoreServices

View File

@@ -8485,7 +8485,7 @@ with pkgs;
})
garage
garage_0_8 garage_0_9
garage_0_8_6 garage_0_9_2;
garage_0_8_7 garage_0_9_3;
garmin-plugin = callPackage ../applications/misc/garmin-plugin { };
@@ -40800,7 +40800,7 @@ with pkgs;
nix-melt = callPackage ../tools/nix/nix-melt { };
nixos-option = callPackage ../tools/nix/nixos-option {
nix = nixVersions.nix_2_15;
nix = nixVersions.nix_2_18;
};
nix-pin = callPackage ../tools/package-management/nix-pin { };