52 lines
1.3 KiB
Nix
52 lines
1.3 KiB
Nix
{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;
|
||
sLib = (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 = sLib.mkNeovimPkg {inherit (value) modules;};
|
||
};
|
||
packagesList = map buildPackage (attrsToList cfg.packages);
|
||
in {
|
||
options.sloth = {
|
||
lib = mkOption {
|
||
type = types.attrs;
|
||
description = "sloth’s 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;
|
||
});
|
||
};
|
||
}
|