Merge pull request #314722 from abysssol/ollama-split-listenaddress
nixos/ollama: split `listenAddress` into `host` and `port`
This commit is contained in:
commit
c01818d57c
@ -11,6 +11,11 @@ let
|
|||||||
};
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
imports = [
|
||||||
|
(lib.mkRemovedOptionModule [ "services" "ollama" "listenAddress" ]
|
||||||
|
"Use `services.ollama.host` and `services.ollama.port` instead.")
|
||||||
|
];
|
||||||
|
|
||||||
options = {
|
options = {
|
||||||
services.ollama = {
|
services.ollama = {
|
||||||
enable = lib.mkEnableOption "ollama server for local large language models";
|
enable = lib.mkEnableOption "ollama server for local large language models";
|
||||||
@ -64,12 +69,20 @@ in
|
|||||||
See also `services.ollama.sandbox`.
|
See also `services.ollama.sandbox`.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
listenAddress = lib.mkOption {
|
host = lib.mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
default = "127.0.0.1:11434";
|
default = "127.0.0.1";
|
||||||
example = "0.0.0.0:11111";
|
example = "0.0.0.0";
|
||||||
description = ''
|
description = ''
|
||||||
The address which the ollama server HTTP interface binds and listens to.
|
The host address which the ollama server HTTP interface listens to.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
port = lib.mkOption {
|
||||||
|
type = types.nullOr types.ints.u16;
|
||||||
|
default = 11434;
|
||||||
|
example = 11111;
|
||||||
|
description = ''
|
||||||
|
Which port the ollama server listens to. Set to `null` to not specify a port.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
acceleration = lib.mkOption {
|
acceleration = lib.mkOption {
|
||||||
@ -80,9 +93,9 @@ in
|
|||||||
What interface to use for hardware acceleration.
|
What interface to use for hardware acceleration.
|
||||||
|
|
||||||
- `null`: default behavior
|
- `null`: default behavior
|
||||||
if `nixpkgs.config.rocmSupport` is enabled, uses `"rocm"`
|
- if `nixpkgs.config.rocmSupport` is enabled, uses `"rocm"`
|
||||||
if `nixpkgs.config.cudaSupport` is enabled, uses `"cuda"`
|
- if `nixpkgs.config.cudaSupport` is enabled, uses `"cuda"`
|
||||||
otherwise defaults to `false`
|
- otherwise defaults to `false`
|
||||||
- `false`: disable GPU, only use CPU
|
- `false`: disable GPU, only use CPU
|
||||||
- `"rocm"`: supported by most modern AMD GPUs
|
- `"rocm"`: supported by most modern AMD GPUs
|
||||||
- `"cuda"`: supported by most modern NVIDIA GPUs
|
- `"cuda"`: supported by most modern NVIDIA GPUs
|
||||||
@ -114,7 +127,11 @@ in
|
|||||||
environment = cfg.environmentVariables // {
|
environment = cfg.environmentVariables // {
|
||||||
HOME = cfg.home;
|
HOME = cfg.home;
|
||||||
OLLAMA_MODELS = cfg.models;
|
OLLAMA_MODELS = cfg.models;
|
||||||
OLLAMA_HOST = cfg.listenAddress;
|
OLLAMA_HOST =
|
||||||
|
if cfg.port == null then
|
||||||
|
cfg.host
|
||||||
|
else
|
||||||
|
"${cfg.host}:${toString cfg.port}";
|
||||||
};
|
};
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
ExecStart = "${lib.getExe ollamaPackage} serve";
|
ExecStart = "${lib.getExe ollamaPackage} serve";
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
import ./make-test-python.nix ({ pkgs, lib, ... }:
|
import ./make-test-python.nix ({ pkgs, lib, ... }:
|
||||||
let
|
let
|
||||||
mainPort = "11434";
|
mainPort = 11434;
|
||||||
altPort = "11435";
|
altPort = 11435;
|
||||||
|
|
||||||
curlRequest = port: request:
|
curlRequest = port: request:
|
||||||
"curl http://127.0.0.1:${port}/api/generate -d '${builtins.toJSON request}'";
|
"curl http://127.0.0.1:${toString port}/api/generate -d '${builtins.toJSON request}'";
|
||||||
|
|
||||||
prompt = {
|
prompt = {
|
||||||
model = "tinydolphin";
|
model = "tinydolphin";
|
||||||
@ -38,7 +38,7 @@ in
|
|||||||
|
|
||||||
altAddress = { ... }: {
|
altAddress = { ... }: {
|
||||||
services.ollama.enable = true;
|
services.ollama.enable = true;
|
||||||
services.ollama.listenAddress = "127.0.0.1:${altPort}";
|
services.ollama.port = altPort;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user