New Ollama.nix, the ai.nix did not work out. Added ZED-editor as separate app

This commit is contained in:
2026-02-28 15:04:36 +01:00
parent c71062b835
commit d0314fab5e
3 changed files with 327 additions and 419 deletions
+7 -37
View File
@@ -1,43 +1,13 @@
{ lib, config, pkgs, flakeRoot, ... }:
{ lib, pkgs, flakeRoot }:
let
# Path to the config file
ollamaConfPath = flakeRoot + "/apps/ai/ollama/ollama.conf";
ollamaConf = builtins.readFile ollamaConfPath;
# Simple parser for key="value" format that takes the last value
parseConf = lines:
lib.foldl' (acc, line)
(if builtins.match "^[^=]+=\"[^\"]+\"$" line != null
then let
parts = builtins.splitString "\"" line;
key = builtins.substring 0 (builtins.stringLength parts.0 - 1) parts.0;
value = parts.1;
in acc // { ${key} = value; }
else acc)
{}
(lib.filter (line: line != "" && ! (lib.hasPrefix "#" line)) (lib.splitString "\n" ollamaConf));
conf = parseConf ollamaConf;
in
{
# Install Ollama package
home.packages = with pkgs; [ ollama ];
# Set environment variables
home.sessionVariables = {
OLLAMA_HOST = conf.OLLAMA_HOST or "http://127.0.0.1:11434";
OLAMA_DEFAULT_MODEL = conf.OLAMA_DEFAULT_MODEL or "codellama:70b";
};
# Configure and enable Ollama service
systemd.user.services.ollama = {
description = "Ollama service";
wantedBy = [ "default.target" ];
serviceConfig = {
ExecStart = "${pkgs.ollama}/bin/ollama serve";
Restart = "on-failure";
Environment = "OLLAMA_HOST=${conf.OLLAMA_HOST or "http://127.0.0.1:11434"}";
};
services.ollama = {
enable = true;
package = pkgs.ollama;
configFile = ollamaConfPath;
environmentFile = builtins.readFile ollamaConfPath;
wantedBy = [ "multi-user.target" ];
};
}