sloth-flake.nvim/flakeModule.nix

52 lines
1.3 KiB
Nix
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

{config, ...}: {
config.flake.flakeModules.default = {
lib,
flake-parts-lib,
...
}: let
inherit (lib) attrsToList listToAttrs mkOption types;
inherit (flake-parts-lib) mkPerSystemOption;
topConfig = config;
in {
options.perSystem = mkPerSystemOption ({
pkgs,
config,
...
}: let
cfg = config.sloth;
inherit (cfg) lib;
packageModule = types.submodule {
options.modules = mkOption {
description = "modules used to create your neovim package";
type = with types; listOf attrs;
default = [];
};
};
buildPackage = { name, value }: {
inherit name;
value = (lib.evalSlothModules {inherit (value) modules;}).neovimPackage;
};
packagesList = map buildPackage (attrsToList cfg.packages);
in {
options.sloth = {
lib = mkOption {
type = types.attrs;
description = "sloths lib";
default = topConfig.flake.mkLib {inherit pkgs;};
defaultText = "mkLib { inherit pkgs; }";
};
packages = mkOption {
description = "neovim package to create with sloth";
default = {};
type = with types; attrsOf packageModule;
};
};
config.packages = listToAttrs packagesList;
});
};
}