diff options
Diffstat (limited to 'nix')
| -rw-r--r-- | nix/lib/mkSystem.nix | 3 | ||||
| -rw-r--r-- | nix/users/fcuny/configs/emacs/site-lisp/init-llm.el | 19 | ||||
| -rw-r--r-- | nix/users/fcuny/home-manager.nix | 1 | ||||
| -rw-r--r-- | nix/users/fcuny/secrets.nix | 17 |
4 files changed, 29 insertions, 11 deletions
diff --git a/nix/lib/mkSystem.nix b/nix/lib/mkSystem.nix index 9cc504b..7c438b6 100644 --- a/nix/lib/mkSystem.nix +++ b/nix/lib/mkSystem.nix @@ -40,6 +40,9 @@ systemFunc rec { { home-manager.useGlobalPkgs = true; home-manager.useUserPackages = true; + home-manager.sharedModules = [ + inputs.agenix.homeManagerModules.default + ]; home-manager.users.${user} = import userHMConfig { inputs = inputs; darwin = darwin; diff --git a/nix/users/fcuny/configs/emacs/site-lisp/init-llm.el b/nix/users/fcuny/configs/emacs/site-lisp/init-llm.el index 4654613..48346e6 100644 --- a/nix/users/fcuny/configs/emacs/site-lisp/init-llm.el +++ b/nix/users/fcuny/configs/emacs/site-lisp/init-llm.el @@ -6,22 +6,19 @@ ;; Configure completions ;;; Code: -(defvar fcuny/op-item-cache nil) +(require 's) -(defun fcuny/read-op-item (op-item-path) - "Read and cache OP-ITEM-PATH item." - (or (cdr (assoc op-item-path fcuny/op-item-cache)) - (let ((key (string-trim-right - (shell-command-to-string (format "op read '%s'" op-item-path))))) - (unless (string-match-p "\\[ERROR\\]" key) - (push (cons op-item-path key) fcuny/op-item-cache) - key)))) +(defun fcuny/read-anthropic-key () + "Read and return the API key for anthropic." + (with-temp-buffer + (insert-file-contents "~/.local/share/agenix/anthropic-api-key") + (s-trim (buffer-string)))) (use-package gptel :custom (gptel-default-mode 'org-mode) :config - (gptel-make-anthropic "Claude" :stream t :key (lambda () (fcuny/read-op-item "op://Private/anthropic llm/credential")))) + (gptel-make-anthropic "Claude" :stream t :key (lambda () (fcuny/read-anthropic-key)))) (use-package aidermacs :bind ("C-c a" . aidermacs-transient-menu) @@ -29,7 +26,7 @@ (aider-args '("--no-check-update" "--no-show-model-warnings")) (aidermacs-default-model "claude-3-7-sonnet-latest") :config - (setenv "ANTHROPIC_API_KEY" (fcuny/read-op-item "op://Private/anthropic llm/credential"))) + (setenv "ANTHROPIC_API_KEY" (fcuny/read-anthropic-key))) (provide 'init-llm) diff --git a/nix/users/fcuny/home-manager.nix b/nix/users/fcuny/home-manager.nix index ae8c319..54b5ad7 100644 --- a/nix/users/fcuny/home-manager.nix +++ b/nix/users/fcuny/home-manager.nix @@ -21,6 +21,7 @@ in ./1password.nix ./dev.nix ./media.nix + ./secrets.nix ] ++ lib.optionals (machineUtils.isMachineType "work" systemName) [ ./work.nix ] ++ lib.optionals (machineUtils.isMachineType "personal" systemName) [ ./personal.nix ]; diff --git a/nix/users/fcuny/secrets.nix b/nix/users/fcuny/secrets.nix new file mode 100644 index 0000000..0b6f7b6 --- /dev/null +++ b/nix/users/fcuny/secrets.nix @@ -0,0 +1,17 @@ +{ config, ... }: +{ + age = { + identityPaths = [ "${config.home.homeDirectory}/.ssh/nixos" ]; + secretsDir = "${config.home.homeDirectory}/.local/share/agenix"; + + secrets = { + llm = { + file = ../../../secrets/users/fcuny/llm.age; + path = "${config.home.homeDirectory}/.config/llm/keys.json"; + }; + anthropic-api-key = { + file = ../../../secrets/users/fcuny/anthropic-api-key.age; + }; + }; + }; +} |
