From fd05e142c4b7d3255a45aaebc7dae9882b189870 Mon Sep 17 00:00:00 2001 From: Henro Veijer Date: Sat, 28 Feb 2026 14:48:18 +0100 Subject: [PATCH] Some regexes did not work out --- henrovnix_ok/README.org | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/henrovnix_ok/README.org b/henrovnix_ok/README.org index aab9dd47a..04f4f7364 100755 --- a/henrovnix_ok/README.org +++ b/henrovnix_ok/README.org @@ -1641,16 +1641,18 @@ This module will import all necessities. This Home Manager Nix module (ai.nix) installs the Ollama package and configures it by reading a simple key-value configuration file (ollama.conf) for settings like the server host and default model. It sets environment variables (OLLAMA_HOST and OLAMA_DEFAULT_MODEL) for easy access in your shell or applications, with fallback defaults if the config file is missing or empty. Optionally, it also defines a user-level systemd service to automatically start the Ollama server on NixOS or systems with Home Manager’s systemd support enabled. #+begin_src nix :tangle home/apps/ollama.nix :noweb tangle :mkdirp yes -{ lib, config, pkgs, flakeRoot,... }: +{ lib, config, pkgs, flakeRoot, ... }: + let # Path to the config file (relative to your flake or Home Manager root) ollamaConfPath = flakeRoot + "/assets/conf/apps/ai/ollama/ollama.conf"; # Read and parse the config file (assuming it's in shell variable format) ollamaConf = builtins.readFile ollamaConfPath; + # Extract values using regex (adjust if your format differs) extractValue = key: builtins.match - ("(?m)^${key}=\"([^\"]+)\"$" + ollamaConf) - ""; + ("(?m)^${key}=\"([^\"]+)\"$") + ollamaConf; ollamaHost = extractValue "OLLAMA_HOST"; ollamaDefaultModel = extractValue "OLLAMA_DEFAULT_MODEL"; in @@ -1659,11 +1661,13 @@ in home.packages = with pkgs; [ ollama ]; + # Configure Ollama environment variables home.sessionVariables = { OLLAMA_HOST = if ollamaHost != "" then ollamaHost else "http://127.0.0.1:11434"; OLAMA_DEFAULT_MODEL = if ollamaDefaultModel != "" then ollamaDefaultModel else "codellama:70b"; }; + # Optional: Start Ollama service (if using NixOS) systemd.user.services.ollama = { description = "Ollama service"; @@ -1677,6 +1681,7 @@ in }; }; } + #+end_src ** NCSway