users/foo-dogsquared/programs/nixvim: deploy NixVim as separate variant

This setup enables multiple Neovim flavors through wrapper-manager and
can even make multiple NixVim configurations under one home-manager
configuration. Very nice.
This commit is contained in:
Gabriel Arazas 2025-01-21 13:35:44 +08:00
parent b21bd8ade7
commit af94d911c8
No known key found for this signature in database
GPG Key ID: 62104B43D00AA360
2 changed files with 50 additions and 19 deletions

View File

@ -1,5 +1,6 @@
{ inputs { inputs
, lib , lib
, config
, defaultNixConf , defaultNixConf
@ -25,6 +26,10 @@
# Get all of the NUR. # Get all of the NUR.
inputs.nur.overlays.default inputs.nur.overlays.default
# We have this since we want to compile those NixVim configuration
# ourselves.
inputs.nixvim-unstable.overlays.default
]; ];
}; };
homeManagerBranch = "home-manager-unstable"; homeManagerBranch = "home-manager-unstable";
@ -33,6 +38,16 @@
inputs.nur.modules.homeManager.default inputs.nur.modules.homeManager.default
inputs.sops-nix.homeManagerModules.sops inputs.sops-nix.homeManagerModules.sops
inputs.wrapper-manager-fds.homeModules.wrapper-manager inputs.wrapper-manager-fds.homeModules.wrapper-manager
{
_module.args = {
firstSetupArgs = {
baseNixvimModules =
config.setups.nixvim.configs.fiesta.modules
++ config.setups.nixvim.sharedModules;
};
};
}
]; ];
nixvim = { nixvim = {
instance = "fiesta"; instance = "fiesta";

View File

@ -1,19 +1,34 @@
# Take note, this already assumes we're using on top of an already existing # Take note, this already assumes we're using on top of an already existing
# NixVim configuration. See the declarative users configuration for more # NixVim configuration. See the declarative users configuration for more
# details. # details.
{ config, lib, pkgs, ... }: { config, lib, pkgs, firstSetupArgs, ... }:
let let
userCfg = config.users.foo-dogsquared; userCfg = config.users.foo-dogsquared;
cfg = userCfg.programs.nixvim; cfg = userCfg.programs.nixvim;
hmCfg = config; hmCfg = config;
createNixvimFlavor = module:
pkgs.nixvim.makeNixvimWithModule {
inherit pkgs;
module.imports = firstSetupArgs.baseNixvimModules ++ [ module ];
extraSpecialArgs.hmConfig = config;
};
in in
{ {
options.users.foo-dogsquared.programs.nixvim.enable = options.users.foo-dogsquared.programs.nixvim.enable =
lib.mkEnableOption "NixVim setup"; lib.mkEnableOption "NixVim setup";
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
programs.nixvim = { ... }: { # Basically, we're creating Neovim flavors with NixVim so no need for it.
#
# Also another reason we're forcibly disabling that it is heavily assumed
# that it is using the Neovim configuration found from the dotfiles repo.
programs.nixvim.enable = lib.mkForce false;
wrapper-manager.packages.neovim-flavors = {
wrappers.nvim-fiesta.arg0 = let
nvimPkg = createNixvimFlavor {
imports = imports =
[ [
./colorschemes.nix ./colorschemes.nix
@ -26,12 +41,13 @@ in
./lsp.nix ./lsp.nix
./dap.nix ./dap.nix
]; ];
config = {
enable = true;
config = {
# Inherit all of the schemes. # Inherit all of the schemes.
bahaghari.tinted-theming.schemes = hmCfg.bahaghari.tinted-theming.schemes; bahaghari.tinted-theming.schemes = hmCfg.bahaghari.tinted-theming.schemes;
}; };
}; };
in lib.getExe' nvimPkg "nvim";
};
}; };
} }