Loading nixos/modules/services/misc/ollama.nix +25 −8 Original line number Diff line number Diff line Loading @@ -11,6 +11,11 @@ let }; in { imports = [ (lib.mkRemovedOptionModule [ "services" "ollama" "listenAddress" ] "Use `services.ollama.host` and `services.ollama.port` instead.") ]; options = { services.ollama = { enable = lib.mkEnableOption "ollama server for local large language models"; Loading Loading @@ -64,12 +69,20 @@ in See also `services.ollama.sandbox`. ''; }; listenAddress = lib.mkOption { host = lib.mkOption { type = types.str; default = "127.0.0.1:11434"; example = "0.0.0.0:11111"; default = "127.0.0.1"; example = "0.0.0.0"; description = '' 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 = '' The address which the ollama server HTTP interface binds and listens to. Which port the ollama server listens to. Set to `null` to not specify a port. ''; }; acceleration = lib.mkOption { Loading @@ -80,9 +93,9 @@ in What interface to use for hardware acceleration. - `null`: default behavior if `nixpkgs.config.rocmSupport` is enabled, uses `"rocm"` if `nixpkgs.config.cudaSupport` is enabled, uses `"cuda"` otherwise defaults to `false` - if `nixpkgs.config.rocmSupport` is enabled, uses `"rocm"` - if `nixpkgs.config.cudaSupport` is enabled, uses `"cuda"` - otherwise defaults to `false` - `false`: disable GPU, only use CPU - `"rocm"`: supported by most modern AMD GPUs - `"cuda"`: supported by most modern NVIDIA GPUs Loading Loading @@ -114,7 +127,11 @@ in environment = cfg.environmentVariables // { HOME = cfg.home; OLLAMA_MODELS = cfg.models; OLLAMA_HOST = cfg.listenAddress; OLLAMA_HOST = if cfg.port == null then cfg.host else "${cfg.host}:${toString cfg.port}"; }; serviceConfig = { ExecStart = "${lib.getExe ollamaPackage} serve"; Loading nixos/tests/ollama.nix +4 −4 Original line number Diff line number Diff line import ./make-test-python.nix ({ pkgs, lib, ... }: let mainPort = "11434"; altPort = "11435"; mainPort = 11434; altPort = 11435; 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 = { model = "tinydolphin"; Loading Loading @@ -38,7 +38,7 @@ in altAddress = { ... }: { services.ollama.enable = true; services.ollama.listenAddress = "127.0.0.1:${altPort}"; services.ollama.port = altPort; }; }; Loading Loading
nixos/modules/services/misc/ollama.nix +25 −8 Original line number Diff line number Diff line Loading @@ -11,6 +11,11 @@ let }; in { imports = [ (lib.mkRemovedOptionModule [ "services" "ollama" "listenAddress" ] "Use `services.ollama.host` and `services.ollama.port` instead.") ]; options = { services.ollama = { enable = lib.mkEnableOption "ollama server for local large language models"; Loading Loading @@ -64,12 +69,20 @@ in See also `services.ollama.sandbox`. ''; }; listenAddress = lib.mkOption { host = lib.mkOption { type = types.str; default = "127.0.0.1:11434"; example = "0.0.0.0:11111"; default = "127.0.0.1"; example = "0.0.0.0"; description = '' 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 = '' The address which the ollama server HTTP interface binds and listens to. Which port the ollama server listens to. Set to `null` to not specify a port. ''; }; acceleration = lib.mkOption { Loading @@ -80,9 +93,9 @@ in What interface to use for hardware acceleration. - `null`: default behavior if `nixpkgs.config.rocmSupport` is enabled, uses `"rocm"` if `nixpkgs.config.cudaSupport` is enabled, uses `"cuda"` otherwise defaults to `false` - if `nixpkgs.config.rocmSupport` is enabled, uses `"rocm"` - if `nixpkgs.config.cudaSupport` is enabled, uses `"cuda"` - otherwise defaults to `false` - `false`: disable GPU, only use CPU - `"rocm"`: supported by most modern AMD GPUs - `"cuda"`: supported by most modern NVIDIA GPUs Loading Loading @@ -114,7 +127,11 @@ in environment = cfg.environmentVariables // { HOME = cfg.home; OLLAMA_MODELS = cfg.models; OLLAMA_HOST = cfg.listenAddress; OLLAMA_HOST = if cfg.port == null then cfg.host else "${cfg.host}:${toString cfg.port}"; }; serviceConfig = { ExecStart = "${lib.getExe ollamaPackage} serve"; Loading
nixos/tests/ollama.nix +4 −4 Original line number Diff line number Diff line import ./make-test-python.nix ({ pkgs, lib, ... }: let mainPort = "11434"; altPort = "11435"; mainPort = 11434; altPort = 11435; 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 = { model = "tinydolphin"; Loading Loading @@ -38,7 +38,7 @@ in altAddress = { ... }: { services.ollama.enable = true; services.ollama.listenAddress = "127.0.0.1:${altPort}"; services.ollama.port = altPort; }; }; Loading