Loading .git-blame-ignore-revs +3 −0 Original line number Diff line number Diff line Loading @@ -150,3 +150,6 @@ ff5c8f6cc3d1f2e017e86d50965c14b71f00567b # ollama: format with nixfmt-rfc-style (#329353) bdfde18037f8d9f9b641a4016c8ada4dc4cbf856 # nixos/ollama: format with nixfmt-rfc-style (#329561) 246d1ee533810ac1946d863bbd9de9b525818d56 nixos/modules/services/misc/ollama.nix +108 −78 Original line number Diff line number Diff line { config, lib, pkgs, ... }: { config, lib, pkgs, ... }: let inherit (lib) literalExpression types mkBefore; cfg = config.services.ollama; ollamaPackage = cfg.package.override { inherit (cfg) acceleration; }; ollamaPackage = cfg.package.override { inherit (cfg) acceleration; }; staticUser = cfg.user != null && cfg.group != null; in { imports = [ (lib.mkRemovedOptionModule [ "services" "ollama" "listenAddress" ] "Use `services.ollama.host` and `services.ollama.port` instead.") (lib.mkRemovedOptionModule [ "services" "ollama" "sandbox" ] "Set `services.ollama.user` and `services.ollama.group` instead.") (lib.mkRemovedOptionModule [ "services" "ollama" "writablePaths" ] "The `models` directory is now always writable. To make other directories writable, use `systemd.services.ollama.serviceConfig.ReadWritePaths`." ) (lib.mkRemovedOptionModule [ "services" "ollama" "listenAddress" ] "Use `services.ollama.host` and `services.ollama.port` instead.") (lib.mkRemovedOptionModule [ "services" "ollama" "sandbox" ] "Set `services.ollama.user` and `services.ollama.group` instead.") (lib.mkRemovedOptionModule [ "services" "ollama" "writablePaths" ] "The `models` directory is now always writable. To make other directories writable, use `systemd.services.ollama.serviceConfig.ReadWritePaths`." ) ]; options = { Loading Loading @@ -84,7 +99,13 @@ in ''; }; acceleration = lib.mkOption { type = types.nullOr (types.enum [ false "rocm" "cuda" ]); type = types.nullOr ( types.enum [ false "rocm" "cuda" ] ); default = null; example = "rocm"; description = '' Loading Loading @@ -163,16 +184,22 @@ in description = "Server for local large language models"; wantedBy = [ "multi-user.target" ]; after = [ "network.target" ]; environment = cfg.environmentVariables // { environment = cfg.environmentVariables // { HOME = cfg.home; OLLAMA_MODELS = cfg.models; OLLAMA_HOST = "${cfg.host}:${toString cfg.port}"; HSA_OVERRIDE_GFX_VERSION = lib.mkIf (cfg.rocmOverrideGfx != null) cfg.rocmOverrideGfx; } // lib.optionalAttrs (cfg.rocmOverrideGfx != null) { HSA_OVERRIDE_GFX_VERSION = cfg.rocmOverrideGfx; }; serviceConfig = lib.optionalAttrs staticUser { serviceConfig = lib.optionalAttrs staticUser { User = cfg.user; Group = cfg.group; } // { } // { DynamicUser = true; ExecStart = "${lib.getExe ollamaPackage} serve"; WorkingDirectory = cfg.home; Loading Loading @@ -242,5 +269,8 @@ in environment.systemPackages = [ ollamaPackage ]; }; meta.maintainers = with lib.maintainers; [ abysssol onny ]; meta.maintainers = with lib.maintainers; [ abysssol onny ]; } Loading
.git-blame-ignore-revs +3 −0 Original line number Diff line number Diff line Loading @@ -150,3 +150,6 @@ ff5c8f6cc3d1f2e017e86d50965c14b71f00567b # ollama: format with nixfmt-rfc-style (#329353) bdfde18037f8d9f9b641a4016c8ada4dc4cbf856 # nixos/ollama: format with nixfmt-rfc-style (#329561) 246d1ee533810ac1946d863bbd9de9b525818d56
nixos/modules/services/misc/ollama.nix +108 −78 Original line number Diff line number Diff line { config, lib, pkgs, ... }: { config, lib, pkgs, ... }: let inherit (lib) literalExpression types mkBefore; cfg = config.services.ollama; ollamaPackage = cfg.package.override { inherit (cfg) acceleration; }; ollamaPackage = cfg.package.override { inherit (cfg) acceleration; }; staticUser = cfg.user != null && cfg.group != null; in { imports = [ (lib.mkRemovedOptionModule [ "services" "ollama" "listenAddress" ] "Use `services.ollama.host` and `services.ollama.port` instead.") (lib.mkRemovedOptionModule [ "services" "ollama" "sandbox" ] "Set `services.ollama.user` and `services.ollama.group` instead.") (lib.mkRemovedOptionModule [ "services" "ollama" "writablePaths" ] "The `models` directory is now always writable. To make other directories writable, use `systemd.services.ollama.serviceConfig.ReadWritePaths`." ) (lib.mkRemovedOptionModule [ "services" "ollama" "listenAddress" ] "Use `services.ollama.host` and `services.ollama.port` instead.") (lib.mkRemovedOptionModule [ "services" "ollama" "sandbox" ] "Set `services.ollama.user` and `services.ollama.group` instead.") (lib.mkRemovedOptionModule [ "services" "ollama" "writablePaths" ] "The `models` directory is now always writable. To make other directories writable, use `systemd.services.ollama.serviceConfig.ReadWritePaths`." ) ]; options = { Loading Loading @@ -84,7 +99,13 @@ in ''; }; acceleration = lib.mkOption { type = types.nullOr (types.enum [ false "rocm" "cuda" ]); type = types.nullOr ( types.enum [ false "rocm" "cuda" ] ); default = null; example = "rocm"; description = '' Loading Loading @@ -163,16 +184,22 @@ in description = "Server for local large language models"; wantedBy = [ "multi-user.target" ]; after = [ "network.target" ]; environment = cfg.environmentVariables // { environment = cfg.environmentVariables // { HOME = cfg.home; OLLAMA_MODELS = cfg.models; OLLAMA_HOST = "${cfg.host}:${toString cfg.port}"; HSA_OVERRIDE_GFX_VERSION = lib.mkIf (cfg.rocmOverrideGfx != null) cfg.rocmOverrideGfx; } // lib.optionalAttrs (cfg.rocmOverrideGfx != null) { HSA_OVERRIDE_GFX_VERSION = cfg.rocmOverrideGfx; }; serviceConfig = lib.optionalAttrs staticUser { serviceConfig = lib.optionalAttrs staticUser { User = cfg.user; Group = cfg.group; } // { } // { DynamicUser = true; ExecStart = "${lib.getExe ollamaPackage} serve"; WorkingDirectory = cfg.home; Loading Loading @@ -242,5 +269,8 @@ in environment.systemPackages = [ ollamaPackage ]; }; meta.maintainers = with lib.maintainers; [ abysssol onny ]; meta.maintainers = with lib.maintainers; [ abysssol onny ]; }