rebuilding nix files
This commit is contained in:
@@ -6,25 +6,22 @@ let
|
||||
# Path to the ZED configuration template
|
||||
AiRepoConf = flakeRoot + "/assets/conf/apps/ai/ai.conf";
|
||||
|
||||
# Improved environment file parser that handles:
|
||||
# - Lines with multiple '=' characters
|
||||
# - Empty values
|
||||
# - Whitespace around keys and values
|
||||
# - Comments (lines starting with #)
|
||||
# Robust environment file parser
|
||||
envVars = lib.genAttrs (
|
||||
builtins.map (
|
||||
line: let
|
||||
# Remove comments and trim whitespace
|
||||
cleanLine = builtins.trim (builtins.replaceStrings [ "#" ] [ "" ] (builtins.elemAt (builtins.split "#" line) 0));
|
||||
# Trim whitespace from the line
|
||||
trimmed = builtins.trim line;
|
||||
# Skip comments and empty lines
|
||||
isValid = trimmed != "" && (builtins.substr 0 1 trimmed) != "#";
|
||||
# Split on first '=' only
|
||||
parts = builtins.split "=" cleanLine;
|
||||
parts = if isValid then builtins.split "=" trimmed else [ ];
|
||||
# Get key (first part) and trim whitespace
|
||||
key = builtins.trim (builtins.elemAt parts 0);
|
||||
key = if builtins.length parts > 0 then builtins.trim (builtins.elemAt parts 0) else null;
|
||||
# Get value (everything after first '=') and trim whitespace
|
||||
value = builtins.trim (builtins.concatStringsSep "=" (builtins.drop 1 parts));
|
||||
value = if builtins.length parts > 1 then builtins.trim (builtins.concatStringsSep "=" (builtins.drop 1 parts)) else "";
|
||||
in { inherit key value; }
|
||||
) (builtins.filter (line: line != "" && !builtins.startsWith "#" line)
|
||||
(builtins.split "\n" (builtins.readFile (toString AiRepoEnv))))
|
||||
) (builtins.split "\n" (builtins.readFile (toString AiRepoEnv)))
|
||||
) (entry: entry.key);
|
||||
in
|
||||
{
|
||||
@@ -76,6 +73,12 @@ in
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
# Filter out null entries from envVars
|
||||
home.file.".config/ai-env-test".text = lib.mkForce (
|
||||
builtins.toJSON envVars
|
||||
);
|
||||
|
||||
# --- Usage Notes ---
|
||||
# 1. Pulling Additional Models:
|
||||
# To add more models later, run:
|
||||
|
||||
Reference in New Issue
Block a user