Merge pull request #280 from NotAShelf/rename-module-opts

flake/modules: alias `programs.nvf` to `programs.neovim-flake`
This commit is contained in:
raf 2024-05-06 06:54:59 +00:00 committed by GitHub
commit a777941eed
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 26 additions and 18 deletions

View file

@ -6,12 +6,12 @@ packages: inputs: {
... ...
}: let }: let
inherit (lib) maintainers; inherit (lib) maintainers;
inherit (lib.modules) mkIf; inherit (lib.modules) mkIf mkAliasOptionModule;
inherit (lib.lists) optional; inherit (lib.lists) optional;
inherit (lib.options) mkOption mkEnableOption literalExpression; inherit (lib.options) mkOption mkEnableOption literalExpression;
inherit (lib.types) attrsOf anything bool; inherit (lib.types) attrsOf anything bool;
cfg = config.programs.neovim-flake; cfg = config.programs.nvf;
inherit (import ../../configuration.nix inputs) neovimConfiguration; inherit (import ../../configuration.nix inputs) neovimConfiguration;
neovimConfigured = neovimConfiguration { neovimConfigured = neovimConfiguration {
@ -19,22 +19,26 @@ packages: inputs: {
modules = [cfg.settings]; modules = [cfg.settings];
}; };
in { in {
imports = [
(mkAliasOptionModule ["programs" "neovim-flake"] ["programs" "nvf"])
];
meta.maintainers = with maintainers; [NotAShelf]; meta.maintainers = with maintainers; [NotAShelf];
options.programs.neovim-flake = { options.programs.nvf = {
enable = mkEnableOption "neovim-flake, the extensible neovim configuration wrapper"; enable = mkEnableOption "nvf, the extensible neovim configuration wrapper";
enableManpages = mkOption { enableManpages = mkOption {
type = bool; type = bool;
default = false; default = false;
description = "Whether to enable manpages for neovim-flake."; description = "Whether to enable manpages for nvf.";
}; };
defaultEditor = mkOption { defaultEditor = mkOption {
type = bool; type = bool;
default = false; default = false;
description = '' description = ''
Whether to set `neovim-flake` as the default editor. Whether to set `nvf` as the default editor.
This will set the `EDITOR` environment variable as `nvim` This will set the `EDITOR` environment variable as `nvim`
if set to true. if set to true.
@ -46,14 +50,14 @@ in {
visible = false; visible = false;
readOnly = true; readOnly = true;
description = '' description = ''
The built neovim-flake package, wrapped with the user's configuration. The built nvf package, wrapped with the user's configuration.
''; '';
}; };
settings = mkOption { settings = mkOption {
type = attrsOf anything; type = attrsOf anything;
default = {}; default = {};
description = "Attribute set of neovim-flake preferences."; description = "Attribute set of nvf preferences.";
example = literalExpression '' example = literalExpression ''
{ {
vim.viAlias = false; vim.viAlias = false;
@ -75,7 +79,7 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
programs.neovim-flake.finalPackage = neovimConfigured.neovim; programs.nvf.finalPackage = neovimConfigured.neovim;
home = { home = {
sessionVariables = mkIf cfg.defaultEditor {EDITOR = "nvim";}; sessionVariables = mkIf cfg.defaultEditor {EDITOR = "nvim";};

View file

@ -6,12 +6,12 @@ packages: inputs: {
... ...
}: let }: let
inherit (lib) maintainers; inherit (lib) maintainers;
inherit (lib.modules) mkIf mkOverride; inherit (lib.modules) mkIf mkOverride mkAliasOptionModule;
inherit (lib.lists) optional; inherit (lib.lists) optional;
inherit (lib.options) mkOption mkEnableOption literalExpression; inherit (lib.options) mkOption mkEnableOption literalExpression;
inherit (lib.types) attrsOf anything bool; inherit (lib.types) attrsOf anything bool;
cfg = config.programs.neovim-flake; cfg = config.programs.nvf;
inherit (import ../../configuration.nix inputs) neovimConfiguration; inherit (import ../../configuration.nix inputs) neovimConfiguration;
neovimConfigured = neovimConfiguration { neovimConfigured = neovimConfiguration {
@ -19,22 +19,26 @@ packages: inputs: {
modules = [cfg.settings]; modules = [cfg.settings];
}; };
in { in {
imports = [
(mkAliasOptionModule ["programs" "neovim-flake"] ["programs" "nvf"])
];
meta.maintainers = with maintainers; [NotAShelf]; meta.maintainers = with maintainers; [NotAShelf];
options.programs.neovim-flake = { options.programs.nvf = {
enable = mkEnableOption "neovim-flake, the extensible neovim configuration wrapper"; enable = mkEnableOption "nvf, the extensible neovim configuration wrapper";
enableManpages = mkOption { enableManpages = mkOption {
type = bool; type = bool;
default = false; default = false;
description = "Whether to enable manpages for neovim-flake."; description = "Whether to enable manpages for nvf.";
}; };
defaultEditor = mkOption { defaultEditor = mkOption {
type = bool; type = bool;
default = false; default = false;
description = '' description = ''
Whether to set `neovim-flake` as the default editor. Whether to set `nvf` as the default editor.
This will set the `EDITOR` environment variable as `nvim` This will set the `EDITOR` environment variable as `nvim`
if set to true. if set to true.
@ -46,14 +50,14 @@ in {
visible = false; visible = false;
readOnly = true; readOnly = true;
description = '' description = ''
The built neovim-flake package, wrapped with the user's configuration. The built nvf package, wrapped with the user's configuration.
''; '';
}; };
settings = mkOption { settings = mkOption {
type = attrsOf anything; type = attrsOf anything;
default = {}; default = {};
description = "Attribute set of neovim-flake preferences."; description = "Attribute set of nvf preferences.";
example = literalExpression '' example = literalExpression ''
{ {
vim.viAlias = false; vim.viAlias = false;
@ -75,7 +79,7 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
programs.neovim-flake.finalPackage = neovimConfigured.neovim; programs.nvf.finalPackage = neovimConfigured.neovim;
environment = { environment = {
variables.EDITOR = mkIf cfg.defaultEditor (mkOverride 900 "nvim"); variables.EDITOR = mkIf cfg.defaultEditor (mkOverride 900 "nvim");