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