about summary refs log tree commit diff
diff options
context:
space:
mode:
authorabysssol <abysssol@pm.me>2024-04-07 20:17:15 -0400
committergithub-actions[bot] <github-actions[bot]@users.noreply.github.com>2024-04-08 17:52:52 +0000
commitbfce3d3ddf47cc97b1065f75fc4a720dd68c4aab (patch)
tree8ad50154fdbdcb32315a0d6f14d5df58b248b290
parent8b43e7aa6d16beb1bd971d8355da309898046abb (diff)
nixos/ollama: add options to override `HOME` and `OLLAMA_MODELS`
(cherry picked from commit 18a5476aa7779b916e588e99fb438c631a464d77)
-rw-r--r--nixos/modules/services/misc/ollama.nix20
1 files changed, 18 insertions, 2 deletions
diff --git a/nixos/modules/services/misc/ollama.nix b/nixos/modules/services/misc/ollama.nix
index 7a5661510e251..30c2b26d8322e 100644
--- a/nixos/modules/services/misc/ollama.nix
+++ b/nixos/modules/services/misc/ollama.nix
@@ -15,6 +15,22 @@ in
     services.ollama = {
       enable = lib.mkEnableOption "ollama server for local large language models";
       package = lib.mkPackageOption pkgs "ollama" { };
+      home = lib.mkOption {
+        type = types.str;
+        default = "%S/ollama";
+        example = "/home/foo";
+        description = ''
+          The home directory that the ollama service is started in.
+        '';
+      };
+      models = lib.mkOption {
+        type = types.str;
+        default = "%S/ollama/models";
+        example = "/path/to/ollama/models";
+        description = ''
+          The directory that the ollama service will read models from and download new models to.
+        '';
+      };
       listenAddress = lib.mkOption {
         type = types.str;
         default = "127.0.0.1:11434";
@@ -58,8 +74,8 @@ in
       wantedBy = [ "multi-user.target" ];
       after = [ "network.target" ];
       environment = cfg.environmentVariables // {
-        HOME = "%S/ollama";
-        OLLAMA_MODELS = "%S/ollama/models";
+        HOME = cfg.home;
+        OLLAMA_MODELS = cfg.models;
         OLLAMA_HOST = cfg.listenAddress;
       };
       serviceConfig = {