New Ollama.nix, the ai.nix did not work out. Added ZED-editor as separate app
This commit is contained in:
@@ -6,14 +6,23 @@ let
|
||||
# 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)
|
||||
# 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
|
||||
extractValue = key:
|
||||
let
|
||||
match = builtins.match ("(?m)^${key}=\"([^\"]+)\"$") ollamaConf;
|
||||
# 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) matches;
|
||||
in
|
||||
if match != null && match != [] then
|
||||
# Return the first capture group of the first match
|
||||
builtins.elemAt (builtins.elemAt match 0) 1
|
||||
if nonNullMatches != [] then
|
||||
# Return the first capture group of the last match
|
||||
builtins.elemAt (builtins.elemAt (lib.elemAt nonNullMatches (lib.length nonNullMatches - 1)) 0) 1
|
||||
else
|
||||
null;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user