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

This commit is contained in:
2026-02-28 14:53:29 +01:00
parent edbc311899
commit 6edfb48480
3 changed files with 357 additions and 381 deletions
+17 -25
View File
@@ -1,33 +1,27 @@
{ lib, config, pkgs, flakeRoot, ... }:
let
# Path to the config file (relative to your flake or Home Manager root)
# Path to the config file
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;
# Split the file into lines and filter out comments/empty lines
lines = lib.filter (line: line != "" && ! (lib.hasPrefix "#" line))
(lib.splitString "\n" ollamaConf);
# Extract the last value for a given key
# Helper function to extract values from key="value" lines
extractValue = key:
let
# Find all lines matching the key
matches = lib.map (
line: builtins.match ("^${key}=\"([^\"]+)\"$") line
) lines;
# Filter out null matches and get the last one
nonNullMatches = lib.filter (match: match != null && match != []) matches;
# Extract the first capture group from the last match
lastMatch = if nonNullMatches != [] then
builtins.elemAt nonNullMatches (lib.length nonNullMatches - 1)
else
null;
# Split into lines and filter out comments/empty lines
lines = lib.filter (line: line != "" && ! (lib.hasPrefix "#" line))
(lib.splitString "\n" ollamaConf);
# Find the last matching line
matchingLines = lib.filter (line: builtins.match ("^${key}=\"") line != null) lines;
lastLine = if matchingLines != [] then lib.elemAt matchingLines (lib.length matchingLines - 1) else null;
in
if lastMatch != null then
# The first capture group is the second element (index 1) of the match
builtins.elemAt (builtins.elemAt lastMatch 0) 1
if lastLine != null then
# Extract everything after the ="
builtins.substring
(builtins.stringLength (builtins.match ("^${key}=\"") lastLine) + 1)
(builtins.stringLength lastLine - 1) # Remove trailing quote
lastLine
else
null;
@@ -36,9 +30,7 @@ let
in
{
# Install Ollama
home.packages = with pkgs; [
ollama
];
home.packages = with pkgs; [ ollama ];
# Configure Ollama environment variables
home.sessionVariables = {
@@ -46,7 +38,7 @@ in
OLAMA_DEFAULT_MODEL = if ollamaDefaultModel != null then ollamaDefaultModel else "codellama:70b";
};
# Optional: Start Ollama service (if using NixOS)
# Start Ollama service
systemd.user.services.ollama = {
description = "Ollama service";
wantedBy = [ "multi-user.target" ];