flake/modules: add nixos-module; expose builtPackage

This commit is contained in:
raf 2024-04-08 03:28:30 +03:00
parent 51e28d415a
commit cf09a3bb8b
No known key found for this signature in database
GPG key ID: 02D1DD3FA08B6B29
2 changed files with 73 additions and 2 deletions

View file

@ -8,7 +8,7 @@ packages: inputs: {
inherit (lib) maintainers; inherit (lib) maintainers;
inherit (lib.modules) mkIf; inherit (lib.modules) mkIf;
inherit (lib.options) mkOption mkEnableOption literalExpression; inherit (lib.options) mkOption mkEnableOption literalExpression;
inherit (lib.types) attrsOf anything; inherit (lib.types) attrsOf anything package;
cfg = config.programs.neovim-flake; cfg = config.programs.neovim-flake;
inherit (import ../../configuration.nix inputs) neovimConfiguration; inherit (import ../../configuration.nix inputs) neovimConfiguration;
@ -23,9 +23,19 @@ in {
options.programs.neovim-flake = { options.programs.neovim-flake = {
enable = mkEnableOption "neovim-flake, the extensible neovim-wrapper"; enable = mkEnableOption "neovim-flake, the extensible neovim-wrapper";
builtPackage = mkOption {
type = package;
default = builtPackage;
internal = true;
description = ''
The built neovim-flake 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.";
example = literalExpression '' example = literalExpression ''
{ {
vim.viAlias = false; vim.viAlias = false;
@ -43,7 +53,6 @@ in {
}; };
} }
''; '';
description = "Attribute set of neoflake preferences.";
}; };
}; };

62
flake/modules/nixos.nix Normal file
View file

@ -0,0 +1,62 @@
# Home Manager module
packages: inputs: {
config,
pkgs,
lib ? pkgs.lib,
...
}: let
inherit (lib) maintainers;
inherit (lib.modules) mkIf;
inherit (lib.options) mkOption mkEnableOption literalExpression;
inherit (lib.types) attrsOf package anything;
cfg = config.programs.neovim-flake;
inherit (import ../../configuration.nix inputs) neovimConfiguration;
builtPackage = neovimConfiguration {
inherit pkgs;
modules = [cfg.settings];
};
in {
meta.maintainers = with maintainers; [NotAShelf];
options.programs.neovim-flake = {
enable = mkEnableOption "neovim-flake, the extensible neovim-wrapper";
builtPackage = mkOption {
type = package;
default = builtPackage;
internal = true;
description = ''
The built neovim-flake package, wrapped with the user's configuration.
'';
};
settings = mkOption {
type = attrsOf anything;
default = {};
description = "Attribute set of neovim-flake preferences.";
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;
};
}
'';
};
};
config = mkIf cfg.enable {
environment.systemPackages = [builtPackage];
};
}