New Ollama.nix, the ai.nix did not work out. Added ZED-editor as separate app
This commit is contained in:
@@ -7,9 +7,16 @@ let
|
||||
ollamaConf = builtins.readFile ollamaConfPath;
|
||||
|
||||
# Extract values using regex (adjust if your format differs)
|
||||
extractValue = key: builtins.match
|
||||
("(?m)^${key}=\"([^\"]+)\"$")
|
||||
ollamaConf;
|
||||
extractValue = key:
|
||||
let
|
||||
match = builtins.match ("(?m)^${key}=\"([^\"]+)\"$") ollamaConf;
|
||||
in
|
||||
if match != null && match != [] then
|
||||
# Return the first capture group of the first match
|
||||
builtins.elemAt (builtins.elemAt match 0) 1
|
||||
else
|
||||
null;
|
||||
|
||||
ollamaHost = extractValue "OLLAMA_HOST";
|
||||
ollamaDefaultModel = extractValue "OLLAMA_DEFAULT_MODEL";
|
||||
in
|
||||
@@ -21,8 +28,8 @@ in
|
||||
|
||||
# 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";
|
||||
OLLAMA_HOST = if ollamaHost != null then ollamaHost else "http://127.0.0.1:11434";
|
||||
OLAMA_DEFAULT_MODEL = if ollamaDefaultModel != null then ollamaDefaultModel else "codellama:70b";
|
||||
};
|
||||
|
||||
# Optional: Start Ollama service (if using NixOS)
|
||||
@@ -33,7 +40,7 @@ in
|
||||
ExecStart = "${pkgs.ollama}/bin/ollama serve";
|
||||
Restart = "on-failure";
|
||||
Environment = [
|
||||
"OLLAMA_HOST=${if ollamaHost != "" then ollamaHost else "http://127.0.0.1:11434"}"
|
||||
"OLLAMA_HOST=${if ollamaHost != null then ollamaHost else "http://127.0.0.1:11434"}"
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user