2023-03-31 14:42:05 +00:00
|
|
|
# Home Manager module
|
2023-04-01 12:19:46 +00:00
|
|
|
packages: inputs: {
|
2023-03-31 15:17:06 +00:00
|
|
|
config,
|
2024-04-07 14:16:08 +00:00
|
|
|
pkgs,
|
2023-03-31 15:17:06 +00:00
|
|
|
lib ? pkgs.lib,
|
|
|
|
...
|
2024-04-07 14:16:08 +00:00
|
|
|
}: let
|
|
|
|
inherit (lib) maintainers;
|
2024-05-04 10:27:50 +00:00
|
|
|
inherit (lib.modules) mkIf mkAliasOptionModule;
|
2024-04-20 21:10:00 +00:00
|
|
|
inherit (lib.lists) optional;
|
2024-04-07 14:16:08 +00:00
|
|
|
inherit (lib.options) mkOption mkEnableOption literalExpression;
|
2024-04-20 16:00:58 +00:00
|
|
|
inherit (lib.types) attrsOf anything bool;
|
2024-04-07 14:16:08 +00:00
|
|
|
|
2024-05-04 10:27:50 +00:00
|
|
|
cfg = config.programs.nvf;
|
2023-07-11 21:15:23 +00:00
|
|
|
inherit (import ../../configuration.nix inputs) neovimConfiguration;
|
2024-04-07 14:16:08 +00:00
|
|
|
|
2024-04-14 14:13:57 +00:00
|
|
|
neovimConfigured = neovimConfiguration {
|
2023-04-01 12:19:46 +00:00
|
|
|
inherit pkgs;
|
|
|
|
modules = [cfg.settings];
|
|
|
|
};
|
2023-03-31 15:17:06 +00:00
|
|
|
in {
|
2024-05-04 10:27:50 +00:00
|
|
|
imports = [
|
|
|
|
(mkAliasOptionModule ["programs" "neovim-flake"] ["programs" "nvf"])
|
|
|
|
];
|
|
|
|
|
2023-07-11 21:15:23 +00:00
|
|
|
meta.maintainers = with maintainers; [NotAShelf];
|
2023-03-31 14:42:05 +00:00
|
|
|
|
2024-05-04 10:27:50 +00:00
|
|
|
options.programs.nvf = {
|
|
|
|
enable = mkEnableOption "nvf, the extensible neovim configuration wrapper";
|
2024-04-20 16:00:58 +00:00
|
|
|
|
|
|
|
enableManpages = mkOption {
|
|
|
|
type = bool;
|
|
|
|
default = false;
|
2024-05-04 10:27:50 +00:00
|
|
|
description = "Whether to enable manpages for nvf.";
|
2024-04-20 16:00:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
defaultEditor = mkOption {
|
|
|
|
type = bool;
|
|
|
|
default = false;
|
|
|
|
description = ''
|
2024-05-04 10:27:50 +00:00
|
|
|
Whether to set `nvf` as the default editor.
|
2024-04-20 16:00:58 +00:00
|
|
|
|
|
|
|
This will set the `EDITOR` environment variable as `nvim`
|
|
|
|
if set to true.
|
|
|
|
'';
|
|
|
|
};
|
2024-04-14 14:02:39 +00:00
|
|
|
|
2024-04-14 14:13:57 +00:00
|
|
|
finalPackage = mkOption {
|
2024-04-14 14:02:39 +00:00
|
|
|
type = anything;
|
2024-04-14 14:13:57 +00:00
|
|
|
visible = false;
|
|
|
|
readOnly = true;
|
2024-04-14 14:02:39 +00:00
|
|
|
description = ''
|
2024-05-04 10:27:50 +00:00
|
|
|
The built nvf package, wrapped with the user's configuration.
|
2024-04-14 14:02:39 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2023-03-31 15:17:06 +00:00
|
|
|
settings = mkOption {
|
2024-04-07 14:16:08 +00:00
|
|
|
type = attrsOf anything;
|
2023-03-31 15:17:06 +00:00
|
|
|
default = {};
|
2024-05-04 10:27:50 +00:00
|
|
|
description = "Attribute set of nvf preferences.";
|
2023-03-31 15:17:06 +00:00
|
|
|
example = literalExpression ''
|
|
|
|
{
|
|
|
|
vim.viAlias = false;
|
|
|
|
vim.vimAlias = true;
|
|
|
|
vim.lsp = {
|
|
|
|
enable = true;
|
|
|
|
formatOnSave = true;
|
|
|
|
lightbulb.enable = true;
|
|
|
|
lspsaga.enable = false;
|
|
|
|
nvimCodeActionMenu.enable = true;
|
|
|
|
trouble.enable = true;
|
|
|
|
lspSignature.enable = true;
|
|
|
|
rust.enable = false;
|
|
|
|
nix = true;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
'';
|
2023-03-31 14:42:05 +00:00
|
|
|
};
|
2023-03-31 15:17:06 +00:00
|
|
|
};
|
|
|
|
|
2024-04-20 20:42:48 +00:00
|
|
|
config = mkIf cfg.enable {
|
2024-05-04 10:27:50 +00:00
|
|
|
programs.nvf.finalPackage = neovimConfigured.neovim;
|
2024-04-14 14:13:57 +00:00
|
|
|
|
2024-04-20 20:42:48 +00:00
|
|
|
home = {
|
2024-04-20 20:48:15 +00:00
|
|
|
sessionVariables = mkIf cfg.defaultEditor {EDITOR = "nvim";};
|
2024-04-20 20:42:48 +00:00
|
|
|
packages =
|
|
|
|
[cfg.finalPackage]
|
2024-04-20 21:10:00 +00:00
|
|
|
++ optional cfg.enableManpages packages.${pkgs.stdenv.system}.docs-manpages;
|
2024-04-20 20:42:48 +00:00
|
|
|
};
|
|
|
|
};
|
2024-07-08 21:57:58 +00:00
|
|
|
_file = ./home-manager.nix;
|
2023-03-31 15:05:28 +00:00
|
|
|
}
|