From 72e98aa61c24ec5af3480c6dab3e5d644dccee76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Thu, 24 Oct 2024 20:32:29 +0200 Subject: [PATCH] refactor: add ai config option --- hosts/nixos-desktop/default.nix | 1 + modules/config/ai.nix | 8 +++ modules/programs/nvim/new_plugins/avante.nix | 64 +++++++++++--------- 3 files changed, 43 insertions(+), 30 deletions(-) create mode 100644 modules/config/ai.nix diff --git a/hosts/nixos-desktop/default.nix b/hosts/nixos-desktop/default.nix index d60744f..b3d88b7 100644 --- a/hosts/nixos-desktop/default.nix +++ b/hosts/nixos-desktop/default.nix @@ -14,6 +14,7 @@ ]; my = { + ai.enable = true; profiles = { desktop.enable = true; gaming.enable = true; diff --git a/modules/config/ai.nix b/modules/config/ai.nix new file mode 100644 index 0000000..0f5a57e --- /dev/null +++ b/modules/config/ai.nix @@ -0,0 +1,8 @@ +{ lib +, ... +}: + +with lib; +{ + options.my.ai.enable = mkEnableOption "AI stuff"; +} diff --git a/modules/programs/nvim/new_plugins/avante.nix b/modules/programs/nvim/new_plugins/avante.nix index d01ed84..1b807d2 100644 --- a/modules/programs/nvim/new_plugins/avante.nix +++ b/modules/programs/nvim/new_plugins/avante.nix @@ -1,37 +1,41 @@ -{ config, lib, pkgs, inputs, ... }: +{ config, lib, pkgs, ... }: let - inherit (lib) mkEnableOption mkIf readFile; + inherit (lib) mkIf; + + cfg = config.my.ai; in { - home-manager.users.moritz.programs.nixvim = { - extraPlugins = with pkgs.vimPlugins; [ - nui-nvim - render-markdown-nvim - avante-nvim - ]; - extraConfigLuaPost = '' - require("render-markdown").setup({ file_types = {"markdown", "Avante"} }) + config = mkIf cfg.enable { + home-manager.users.moritz.programs.nixvim = { + extraPlugins = with pkgs.vimPlugins; [ + nui-nvim + render-markdown-nvim + avante-nvim + ]; + extraConfigLuaPost = '' + require("render-markdown").setup({ file_types = {"markdown", "Avante"} }) - require("avante_lib").load() - require("avante").setup({ - provider = "openai", - auto_suggestions_provider = "openai", - behaviour = { - -- auto_suggestions = true, - }, - openai = { - model = "gpt-4o", - api_key_name = "cmd:cat /run/agenix/openai" - } - }) - ''; - # plugins.copilot-lua.enable = true; - # plugins.copilot-lua.suggestion.enabled = false; - # plugins.copilot-lua.panel.enabled = false; - plugins.dressing.enable = true; - # performance.combinePlugins.standalonePlugins = [ "copilot.lua" ]; + require("avante_lib").load() + require("avante").setup({ + provider = "openai", + auto_suggestions_provider = "openai", + behaviour = { + -- auto_suggestions = true, + }, + openai = { + model = "gpt-4o", + api_key_name = "cmd:cat /run/agenix/openai" + } + }) + ''; + plugins.dressing.enable = true; + }; + age.secrets = { + "openai".file = ../../../../secrets/openai.age; + "openai".owner = "moritz"; + anthropic.file = ../../../../secrets/anthropic.age; + anthropic.owner = "moritz"; + }; }; - age.secrets."openai".file = ../../../../secrets/openai.age; - age.secrets."openai".owner = "moritz"; }