New Ollama.nix, the ai.nix did not work out. Added ZED-editor as separate app
This commit is contained in:
+323
-331
File diff suppressed because it is too large
Load Diff
+17
-25
@@ -1644,33 +1644,27 @@ This Home Manager Nix module (ai.nix) installs the Ollama package and configures
|
|||||||
{ 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
|
||||||
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)
|
|
||||||
ollamaConf = builtins.readFile ollamaConfPath;
|
ollamaConf = builtins.readFile ollamaConfPath;
|
||||||
|
|
||||||
# Split the file into lines and filter out comments/empty lines
|
# Helper function to extract values from key="value" lines
|
||||||
lines = lib.filter (line: line != "" && ! (lib.hasPrefix "#" line))
|
|
||||||
(lib.splitString "\n" ollamaConf);
|
|
||||||
|
|
||||||
# Extract the last value for a given key
|
|
||||||
extractValue = key:
|
extractValue = key:
|
||||||
let
|
let
|
||||||
# Find all lines matching the key
|
# Split into lines and filter out comments/empty lines
|
||||||
matches = lib.map (
|
lines = lib.filter (line: line != "" && ! (lib.hasPrefix "#" line))
|
||||||
line: builtins.match ("^${key}=\"([^\"]+)\"$") line
|
(lib.splitString "\n" ollamaConf);
|
||||||
) lines;
|
|
||||||
# Filter out null matches and get the last one
|
# Find the last matching line
|
||||||
nonNullMatches = lib.filter (match: match != null && match != []) matches;
|
matchingLines = lib.filter (line: builtins.match ("^${key}=\"") line != null) lines;
|
||||||
# Extract the first capture group from the last match
|
lastLine = if matchingLines != [] then lib.elemAt matchingLines (lib.length matchingLines - 1) else null;
|
||||||
lastMatch = if nonNullMatches != [] then
|
|
||||||
builtins.elemAt nonNullMatches (lib.length nonNullMatches - 1)
|
|
||||||
else
|
|
||||||
null;
|
|
||||||
in
|
in
|
||||||
if lastMatch != null then
|
if lastLine != null then
|
||||||
# The first capture group is the second element (index 1) of the match
|
# Extract everything after the ="
|
||||||
builtins.elemAt (builtins.elemAt lastMatch 0) 1
|
builtins.substring
|
||||||
|
(builtins.stringLength (builtins.match ("^${key}=\"") lastLine) + 1)
|
||||||
|
(builtins.stringLength lastLine - 1) # Remove trailing quote
|
||||||
|
lastLine
|
||||||
else
|
else
|
||||||
null;
|
null;
|
||||||
|
|
||||||
@@ -1679,9 +1673,7 @@ let
|
|||||||
in
|
in
|
||||||
{
|
{
|
||||||
# Install Ollama
|
# Install Ollama
|
||||||
home.packages = with pkgs; [
|
home.packages = with pkgs; [ ollama ];
|
||||||
ollama
|
|
||||||
];
|
|
||||||
|
|
||||||
# Configure Ollama environment variables
|
# Configure Ollama environment variables
|
||||||
home.sessionVariables = {
|
home.sessionVariables = {
|
||||||
@@ -1689,7 +1681,7 @@ in
|
|||||||
OLAMA_DEFAULT_MODEL = if ollamaDefaultModel != null then ollamaDefaultModel else "codellama:70b";
|
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 = {
|
systemd.user.services.ollama = {
|
||||||
description = "Ollama service";
|
description = "Ollama service";
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
|||||||
@@ -1,33 +1,27 @@
|
|||||||
{ 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
|
||||||
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)
|
|
||||||
ollamaConf = builtins.readFile ollamaConfPath;
|
ollamaConf = builtins.readFile ollamaConfPath;
|
||||||
|
|
||||||
# Split the file into lines and filter out comments/empty lines
|
# Helper function to extract values from key="value" lines
|
||||||
lines = lib.filter (line: line != "" && ! (lib.hasPrefix "#" line))
|
|
||||||
(lib.splitString "\n" ollamaConf);
|
|
||||||
|
|
||||||
# Extract the last value for a given key
|
|
||||||
extractValue = key:
|
extractValue = key:
|
||||||
let
|
let
|
||||||
# Find all lines matching the key
|
# Split into lines and filter out comments/empty lines
|
||||||
matches = lib.map (
|
lines = lib.filter (line: line != "" && ! (lib.hasPrefix "#" line))
|
||||||
line: builtins.match ("^${key}=\"([^\"]+)\"$") line
|
(lib.splitString "\n" ollamaConf);
|
||||||
) lines;
|
|
||||||
# Filter out null matches and get the last one
|
# Find the last matching line
|
||||||
nonNullMatches = lib.filter (match: match != null && match != []) matches;
|
matchingLines = lib.filter (line: builtins.match ("^${key}=\"") line != null) lines;
|
||||||
# Extract the first capture group from the last match
|
lastLine = if matchingLines != [] then lib.elemAt matchingLines (lib.length matchingLines - 1) else null;
|
||||||
lastMatch = if nonNullMatches != [] then
|
|
||||||
builtins.elemAt nonNullMatches (lib.length nonNullMatches - 1)
|
|
||||||
else
|
|
||||||
null;
|
|
||||||
in
|
in
|
||||||
if lastMatch != null then
|
if lastLine != null then
|
||||||
# The first capture group is the second element (index 1) of the match
|
# Extract everything after the ="
|
||||||
builtins.elemAt (builtins.elemAt lastMatch 0) 1
|
builtins.substring
|
||||||
|
(builtins.stringLength (builtins.match ("^${key}=\"") lastLine) + 1)
|
||||||
|
(builtins.stringLength lastLine - 1) # Remove trailing quote
|
||||||
|
lastLine
|
||||||
else
|
else
|
||||||
null;
|
null;
|
||||||
|
|
||||||
@@ -36,9 +30,7 @@ let
|
|||||||
in
|
in
|
||||||
{
|
{
|
||||||
# Install Ollama
|
# Install Ollama
|
||||||
home.packages = with pkgs; [
|
home.packages = with pkgs; [ ollama ];
|
||||||
ollama
|
|
||||||
];
|
|
||||||
|
|
||||||
# Configure Ollama environment variables
|
# Configure Ollama environment variables
|
||||||
home.sessionVariables = {
|
home.sessionVariables = {
|
||||||
@@ -46,7 +38,7 @@ in
|
|||||||
OLAMA_DEFAULT_MODEL = if ollamaDefaultModel != null then ollamaDefaultModel else "codellama:70b";
|
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 = {
|
systemd.user.services.ollama = {
|
||||||
description = "Ollama service";
|
description = "Ollama service";
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
|||||||
Reference in New Issue
Block a user