mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2024-11-07 13:45:58 +01:00
flake/modules: add options to set default editor to nixos and home-manager modules
This commit is contained in:
parent
4d8dcc7e49
commit
6d681c2c08
2 changed files with 65 additions and 15 deletions
|
@ -6,9 +6,10 @@ packages: inputs: {
|
|||
...
|
||||
}: let
|
||||
inherit (lib) maintainers;
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit (lib.modules) mkIf mkMerge;
|
||||
inherit (lib.lists) optionals;
|
||||
inherit (lib.options) mkOption mkEnableOption literalExpression;
|
||||
inherit (lib.types) attrsOf anything;
|
||||
inherit (lib.types) attrsOf anything bool;
|
||||
|
||||
cfg = config.programs.neovim-flake;
|
||||
inherit (import ../../configuration.nix inputs) neovimConfiguration;
|
||||
|
@ -21,7 +22,24 @@ in {
|
|||
meta.maintainers = with maintainers; [NotAShelf];
|
||||
|
||||
options.programs.neovim-flake = {
|
||||
enable = mkEnableOption "neovim-flake, the extensible neovim-wrapper";
|
||||
enable = mkEnableOption "neovim-flake, the extensible neovim configuration wrapper";
|
||||
|
||||
enableManpages = mkOption {
|
||||
type = bool;
|
||||
default = false;
|
||||
description = "Whether to enable manpages for neovim-flake.";
|
||||
};
|
||||
|
||||
defaultEditor = mkOption {
|
||||
type = bool;
|
||||
default = false;
|
||||
description = ''
|
||||
Whether to set `neovim-flake` as the default editor.
|
||||
|
||||
This will set the `EDITOR` environment variable as `nvim`
|
||||
if set to true.
|
||||
'';
|
||||
};
|
||||
|
||||
finalPackage = mkOption {
|
||||
type = anything;
|
||||
|
@ -56,9 +74,16 @@ in {
|
|||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
home.packages = [cfg.finalPackage];
|
||||
config = mkIf cfg.enable mkMerge [
|
||||
{
|
||||
programs.neovim-flake.finalPackage = neovimConfigured.neovim;
|
||||
|
||||
programs.neovim-flake.finalPackage = neovimConfigured.neovim;
|
||||
};
|
||||
home = {
|
||||
sessionVariables.EDITOR = mkIf cfg.defaultEditor (lib.mkOverride 900 "nvim");
|
||||
packages =
|
||||
[cfg.finalPackage]
|
||||
++ optionals cfg.enableManpages packages.${pkgs.stdenv.system}.docs-manpages;
|
||||
};
|
||||
}
|
||||
];
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Home Manager module
|
||||
# NixOS module
|
||||
packages: inputs: {
|
||||
config,
|
||||
pkgs,
|
||||
|
@ -6,9 +6,10 @@ packages: inputs: {
|
|||
...
|
||||
}: let
|
||||
inherit (lib) maintainers;
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit (lib.modules) mkIf mkMerge;
|
||||
inherit (lib.lists) optionals;
|
||||
inherit (lib.options) mkOption mkEnableOption literalExpression;
|
||||
inherit (lib.types) attrsOf anything;
|
||||
inherit (lib.types) attrsOf anything bool;
|
||||
|
||||
cfg = config.programs.neovim-flake;
|
||||
inherit (import ../../configuration.nix inputs) neovimConfiguration;
|
||||
|
@ -21,7 +22,24 @@ in {
|
|||
meta.maintainers = with maintainers; [NotAShelf];
|
||||
|
||||
options.programs.neovim-flake = {
|
||||
enable = mkEnableOption "neovim-flake, the extensible neovim-wrapper";
|
||||
enable = mkEnableOption "neovim-flake, the extensible neovim configuration wrapper";
|
||||
|
||||
enableManpages = mkOption {
|
||||
type = bool;
|
||||
default = false;
|
||||
description = "Whether to enable manpages for neovim-flake.";
|
||||
};
|
||||
|
||||
defaultEditor = mkOption {
|
||||
type = bool;
|
||||
default = false;
|
||||
description = ''
|
||||
Whether to set `neovim-flake` as the default editor.
|
||||
|
||||
This will set the `EDITOR` environment variable as `nvim`
|
||||
if set to true.
|
||||
'';
|
||||
};
|
||||
|
||||
finalPackage = mkOption {
|
||||
type = anything;
|
||||
|
@ -56,9 +74,16 @@ in {
|
|||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
environment.systemPackages = [cfg.finalPackage];
|
||||
config = mkIf cfg.enable mkMerge [
|
||||
{
|
||||
programs.neovim-flake.finalPackage = neovimConfigured.neovim;
|
||||
|
||||
programs.neovim-flake.finalPackage = neovimConfigured.neovim;
|
||||
};
|
||||
environment = {
|
||||
variables.EDITOR = mkIf cfg.defaultEditor (lib.mkOverride 900 "nvim");
|
||||
systemPackages =
|
||||
[cfg.finalPackage]
|
||||
++ optionals cfg.enableManpages packages.${pkgs.stdenv.system}.docs-manpages;
|
||||
};
|
||||
}
|
||||
];
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue