Used variables for filenames to import (env + conf)
This commit is contained in:
@@ -1643,13 +1643,15 @@ It ensures the Ollama CLI is available system-wide for interacting with local mo
|
||||
It automatically pulls and prepares selected coding models (e.g., Qwen2.5-Coder and StarCoder2) at system activation.
|
||||
|
||||
#+begin_src nix :tangle home/apps/ai.nix :noweb tangle :mkdirp yes
|
||||
{ config, pkgs, lib, ... }:
|
||||
{ config, pkgs, lib, flakeRoot ... }:
|
||||
|
||||
let
|
||||
# Read environment variables (OLLAMA_HOST and MISTRAL_API_KEY) from a local file.
|
||||
# This keeps sensitive values out of the Nix store and version control.
|
||||
# File format: one KEY=value per line (e.g., MISTRAL_API_KEY=yourkey)
|
||||
envVars = lib.genAttrs (builtins.splitStrings "\n" (builtins.readFile (toString ./assets/conf/apps/ai.env)))
|
||||
|
||||
AiRepoEnv = flakeRoot + "/assets/conf/apps/ai/ai.env";
|
||||
AiRepoConf = flakeRoot + "/assets/conf/apps/ai/ai.conv";
|
||||
envVars = lib.genAttrs (builtins.splitStrings "\n" (builtins.readFile (toString AiRepoEnv)))
|
||||
(nameValue: builtins.splitString "=" nameValue);
|
||||
in
|
||||
{
|
||||
@@ -1664,7 +1666,8 @@ in
|
||||
|
||||
# --- Environment Variables ---
|
||||
# Set OLLAMA_HOST and MISTRAL_API_KEY for ZED and other user applications.
|
||||
# Values are read from ./assets/conf/apps/ai.env.
|
||||
# Values are read from AiRepoEnv.
|
||||
|
||||
home.sessionVariables = {
|
||||
OLLAMA_HOST = envVars.OLLAMA_HOST or "http://127.0.0.1:11434"; # Default Ollama endpoint
|
||||
MISTRAL_API_KEY = envVars.MISTRAL_API_KEY or ""; # Mistral API key (required for cloud models)
|
||||
@@ -1707,7 +1710,7 @@ in
|
||||
# Generate ZED's settings.json with substituted API keys and endpoints.
|
||||
# Base config is read from ./assets/conf/apps/ai.conf, with variables injected.
|
||||
home.file.".config/zed/settings.json".text = lib.mkForce (
|
||||
builtins.readFile (toString ./assets/conf/apps/ai.conf)
|
||||
builtins.readFile (toString AiRepoConf)
|
||||
// ''
|
||||
{
|
||||
"mistral": {
|
||||
|
||||
Reference in New Issue
Block a user