Some regexes did not work out

This commit is contained in:
2026-02-28 14:48:18 +01:00
parent 6b25cf6212
commit fd05e142c4
+7 -2
View File
@@ -1642,15 +1642,17 @@ This Home Manager Nix module (ai.nix) installs the Ollama package and configures
#+begin_src nix :tangle home/apps/ollama.nix :noweb tangle :mkdirp yes #+begin_src nix :tangle home/apps/ollama.nix :noweb tangle :mkdirp yes
{ lib, config, pkgs, flakeRoot, ... }: { lib, config, pkgs, flakeRoot, ... }:
let let
# Path to the config file (relative to your flake or Home Manager root) # Path to the config file (relative to your flake or Home Manager root)
ollamaConfPath = flakeRoot + "/assets/conf/apps/ai/ollama/ollama.conf"; ollamaConfPath = flakeRoot + "/assets/conf/apps/ai/ollama/ollama.conf";
# Read and parse the config file (assuming it's in shell variable format) # Read and parse the config file (assuming it's in shell variable format)
ollamaConf = builtins.readFile ollamaConfPath; ollamaConf = builtins.readFile ollamaConfPath;
# Extract values using regex (adjust if your format differs) # Extract values using regex (adjust if your format differs)
extractValue = key: builtins.match extractValue = key: builtins.match
("(?m)^${key}=\"([^\"]+)\"$" + ollamaConf) ("(?m)^${key}=\"([^\"]+)\"$")
""; ollamaConf;
ollamaHost = extractValue "OLLAMA_HOST"; ollamaHost = extractValue "OLLAMA_HOST";
ollamaDefaultModel = extractValue "OLLAMA_DEFAULT_MODEL"; ollamaDefaultModel = extractValue "OLLAMA_DEFAULT_MODEL";
in in
@@ -1659,11 +1661,13 @@ in
home.packages = with pkgs; [ home.packages = with pkgs; [
ollama ollama
]; ];
# Configure Ollama environment variables # Configure Ollama environment variables
home.sessionVariables = { home.sessionVariables = {
OLLAMA_HOST = if ollamaHost != "" then ollamaHost else "http://127.0.0.1:11434"; OLLAMA_HOST = if ollamaHost != "" then ollamaHost else "http://127.0.0.1:11434";
OLAMA_DEFAULT_MODEL = if ollamaDefaultModel != "" then ollamaDefaultModel else "codellama:70b"; OLAMA_DEFAULT_MODEL = if ollamaDefaultModel != "" then ollamaDefaultModel else "codellama:70b";
}; };
# Optional: Start Ollama service (if using NixOS) # Optional: Start Ollama service (if using NixOS)
systemd.user.services.ollama = { systemd.user.services.ollama = {
description = "Ollama service"; description = "Ollama service";
@@ -1677,6 +1681,7 @@ in
}; };
}; };
} }
#+end_src #+end_src
** NCSway ** NCSway