Skip to content

Commit

Permalink
adding variants
Browse files Browse the repository at this point in the history
  • Loading branch information
ck3mp3r committed Jan 14, 2025
1 parent aad5bee commit d688248
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 23 deletions.
6 changes: 5 additions & 1 deletion config/lua/plugins/avante.lua
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
local status, avante_provider = pcall(vim.api.nvim_get_var, "avante_provider")
if not status then
avante_provider = "copilot"
end
return {
{
"yetone/avante.nvim",
event = "VeryLazy",
lazy = false,
opts = {
provider = "copilot",
provider = avante_provider,
},
dependencies = {
"MunifTanjim/nui.nvim",
Expand Down
75 changes: 53 additions & 22 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
{
description = "A nixvim configuration";

inputs = {
nixpkgs.url = "github:nixos/nixpkgs";
devshell.url = "github:numtide/devshell";
flake-utils.url = "github:numtide/flake-utils";
};

outputs = {
devshell,
nixpkgs,
Expand All @@ -20,28 +18,26 @@
inherit system overlays;
config = {allowUnfree = true;};
};

config = pkgs.callPackage ./nix/config.nix {};

plugins = pkgs.callPackage ./nix/plugins.nix {};
nvim' = avanteProvider: appName:
pkgs.callPackage ./nix/wrapper.nix {
inherit appName;
configPath = "${config}";
runtimePaths =
[
pkgs.vimPlugins.lazy-nvim
]
++ plugins.runtimePaths;
extraVars = plugins.extraVars // {"avante_provider" = avanteProvider;};
};

nvim = pkgs.callPackage ./nix/wrapper.nix {
appName = "nvim";
configPath = "${config}";
runtimePaths =
[
pkgs.vimPlugins.lazy-nvim
]
++ plugins.runtimePaths;
extraVars = plugins.extraVars;
};

individualPackages = with pkgs; {
# Base package set without nvim
basePackages = with pkgs; {
inherit
lua
luarocks
nodejs
nvim
python3
shfmt
stylua
Expand All @@ -50,18 +46,53 @@
;
pip = python3Packages.pip;
};

# Function to create a complete package set with specified avante provider
makePackageSet = avanteProvider: appName:
basePackages
// {
nvim = nvim' avanteProvider appName;
};

# Create both variants
copilotPackages = makePackageSet "copilot" "nvim";
claudePackages = makePackageSet "claude" "nvim";

# Helper function to create a package environment
mkXvimEnv = name: packages:
pkgs.buildEnv {
inherit name;
paths = builtins.attrValues packages;
buildInputs = [pkgs.makeWrapper];
postBuild = ''
if [ -f $out/bin/nvim ]; then
mv $out/bin/nvim $out/bin/${name}
fi
'';
};
in {
formatter = pkgs.alejandra;

# Expose all individual packages from copilotPackages as the base
packages =
individualPackages
copilotPackages
// {
default = pkgs.buildEnv {
name = "xvim packages";
paths = builtins.attrValues individualPackages;
};
# And add our bundled environments
default = mkXvimEnv "xvim" copilotPackages;
claude = mkXvimEnv "xvim-claude" claudePackages;
};

# Apps for direct execution
apps.default = {
type = "app";
program = "${copilotPackages.nvim}/bin/nvim";
};

apps.claude = {
type = "app";
program = "${claudePackages.nvim}/bin/nvim";
};

devShells.default = pkgs.devshell.mkShell {
imports = [(pkgs.devshell.importTOML ./devshell.toml)];
};
Expand Down

0 comments on commit d688248

Please sign in to comment.