mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-11-09 06:55:30 +00:00
lib: split inherits for dag types to match repo style
This commit is contained in:
parent
1627e4dddc
commit
d35d5aded5
1 changed files with 15 additions and 18 deletions
|
|
@ -1,34 +1,31 @@
|
||||||
# From home-manager: https://github.com/nix-community/home-manager/blob/master/modules/lib/types-dag.nix
|
# From home-manager: https://github.com/nix-community/home-manager/blob/master/modules/lib/types-dag.nix
|
||||||
# Used for ordering configuration text.
|
# Used for ordering configuration text.
|
||||||
{lib, ...}: let
|
{
|
||||||
# TODO: inherit from subgroups
|
lib,
|
||||||
inherit
|
nvf-lib,
|
||||||
(lib)
|
...
|
||||||
defaultFunctor
|
}: let
|
||||||
nvim
|
inherit (lib.types) attrsOf defaultFunctor listOf mkOptionType str submodule;
|
||||||
mkIf
|
inherit (lib.modules) mkIf mkOrder;
|
||||||
mkOrder
|
inherit (lib.options) mkOption;
|
||||||
mkOption
|
inherit (nvf-lib.dag) isEntry entryAnywhere;
|
||||||
mkOptionType
|
|
||||||
types
|
|
||||||
;
|
|
||||||
|
|
||||||
dagEntryOf = elemType: let
|
dagEntryOf = elemType: let
|
||||||
submoduleType = types.submodule ({name, ...}: {
|
submoduleType = submodule ({name, ...}: {
|
||||||
options = {
|
options = {
|
||||||
data = mkOption {type = elemType;};
|
data = mkOption {type = elemType;};
|
||||||
after = mkOption {type = with types; listOf str;};
|
after = mkOption {type = listOf str;};
|
||||||
before = mkOption {type = with types; listOf str;};
|
before = mkOption {type = listOf str;};
|
||||||
};
|
};
|
||||||
config = mkIf (elemType.name == "submodule") {
|
config = mkIf (elemType.name == "submodule") {
|
||||||
data._module.args.dagName = name;
|
data._module.args.dagName = name;
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
maybeConvert = def:
|
maybeConvert = def:
|
||||||
if nvim.dag.isEntry def.value
|
if isEntry def.value
|
||||||
then def.value
|
then def.value
|
||||||
else
|
else
|
||||||
nvim.dag.entryAnywhere (
|
entryAnywhere (
|
||||||
if def ? priority
|
if def ? priority
|
||||||
then mkOrder def.priority def.value
|
then mkOrder def.priority def.value
|
||||||
else def.value
|
else def.value
|
||||||
|
|
@ -54,7 +51,7 @@ in rec {
|
||||||
# "actual" attribute name a new submodule argument is provided with
|
# "actual" attribute name a new submodule argument is provided with
|
||||||
# the name `dagName`.
|
# the name `dagName`.
|
||||||
dagOf = elemType: let
|
dagOf = elemType: let
|
||||||
attrEquivalent = types.attrsOf (dagEntryOf elemType);
|
attrEquivalent = attrsOf (dagEntryOf elemType);
|
||||||
in
|
in
|
||||||
mkOptionType rec {
|
mkOptionType rec {
|
||||||
name = "dagOf";
|
name = "dagOf";
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue