diff --git a/config/Ollama.nix b/config/Ollama.nix index 6726630..3dff178 100644 --- a/config/Ollama.nix +++ b/config/Ollama.nix @@ -1,4 +1,3 @@ -# SRC: https://github.com/ollama/ollama { pkgsUnstable, lib, @@ -11,45 +10,39 @@ in { config = lib.mkIf cfg.enable { # Specify default model. - # environment.variables.OLLAMA_MODEL = cfg.primaryModel; - # - # systemd.services = { - # # Enable Ollama server. - # ollama = { - # description = "Ollama LLM server"; - # serviceConfig = { - # Type = "simple"; - # }; - # wantedBy = [ - # "multi-user.target" - # ]; - # script = '' - # HOME=/root ${lib.getExe pkgsUnstable.ollama} serve - # ''; - # }; - # - # # Download Ollama models. - # ollama-pull = { - # description = "Ollama LLM model"; - # after = [ - # "NetworkManager-wait-online.service" - # "ollama.service" - # ]; - # wantedBy = [ - # "multi-user.target" - # ]; - # wants = [ - # "NetworkManager-wait-online.service" - # "ollama.service" - # ]; - # serviceConfig = { - # Type = "simple"; - # }; - # script = '' - # sleep 5 - # ${lib.getExe pkgsUnstable.ollama} pull ${lib.concatStringsSep " " cfg.models} - # ''; - # }; - # }; + environment.variables.OLLAMA_MODEL = cfg.primaryModel; + + systemd.services = { + # Enable Ollama server. + ollama = { + description = "Ollama LLM server"; + wantedBy = [ "multi-user.target" ]; + serviceConfig = { + Type = "simple"; + }; + script = '' + HOME=/root ${lib.getExe pkgsUnstable.ollama} serve + ''; + }; + + # Download Ollama models. + ollama-pull = { + description = "Ollama LLM model"; + wantedBy = [ "multi-user.target" ]; + serviceConfig.Type = "simple"; + after = [ + "NetworkManager-wait-online.service" + "ollama.service" + ]; + wants = [ + "NetworkManager-wait-online.service" + "ollama.service" + ]; + script = '' + sleep 5 + HOME=/root ${lib.getExe pkgsUnstable.ollama} pull ${lib.concatStringsSep " " cfg.models} + ''; + }; + }; }; } diff --git a/config/Purpose.nix b/config/Purpose.nix index 0d06213..d5135fc 100644 --- a/config/Purpose.nix +++ b/config/Purpose.nix @@ -131,7 +131,6 @@ in (lib.mkIf cfg.work { module = { distrobox.enable = true; - ollama.enable = true; package.dev = true; virtmanager.enable = true; docker = { diff --git a/option/Ollama.nix b/option/Ollama.nix index 5de7bd8..90fa03b 100644 --- a/option/Ollama.nix +++ b/option/Ollama.nix @@ -1,16 +1,18 @@ +# SRC: https://github.com/ollama/ollama { config, lib, ... }: let cfg = config.module.ollama; + purpose = config.module.purpose; in { options.module.ollama = { - enable = lib.mkEnableOption "the local LLM server."; + enable = lib.mkEnableOption "the local LLM server." // { default = purpose.work && purpose.desktop; }; models = lib.mkOption { default = [ cfg.primaryModel ]; type = with lib.types; listOf str; }; primaryModel = lib.mkOption { - default = "llama3.2"; + default = "llama3.3"; type = lib.types.str; }; };