mirror of
https://github.com/TECHNOFAB11/kubenix.git
synced 2025-12-12 16:10:05 +01:00
fix(modules): pass correct name as arg
This commit is contained in:
parent
83643b0c75
commit
2801411cc0
1 changed files with 42 additions and 1 deletions
43
modules.nix
43
modules.nix
|
|
@ -6,11 +6,52 @@ with import ./lib.nix { inherit pkgs lib; };
|
||||||
let
|
let
|
||||||
globalConfig = config;
|
globalConfig = config;
|
||||||
|
|
||||||
|
# A submodule (like typed attribute set). See NixOS manual.
|
||||||
|
submodule = opts:
|
||||||
|
let
|
||||||
|
opts' = toList opts;
|
||||||
|
inherit (lib.modules) evalModules;
|
||||||
|
in
|
||||||
|
mkOptionType rec {
|
||||||
|
name = "submodule";
|
||||||
|
check = x: isAttrs x || isFunction x;
|
||||||
|
merge = loc: defs:
|
||||||
|
let
|
||||||
|
coerce = def: if isFunction def then def else { config = def; };
|
||||||
|
modules = opts' ++ map (def: { _file = def.file; imports = [(coerce def.value)]; }) defs;
|
||||||
|
in (evalModules {
|
||||||
|
inherit modules;
|
||||||
|
prefix = loc;
|
||||||
|
}).config;
|
||||||
|
getSubOptions = prefix: (evalModules
|
||||||
|
{ modules = opts'; inherit prefix;
|
||||||
|
# This is a work-around due to the fact that some sub-modules,
|
||||||
|
# such as the one included in an attribute set, expects a "args"
|
||||||
|
# attribute to be given to the sub-module. As the option
|
||||||
|
# evaluation does not have any specific attribute name, we
|
||||||
|
# provide a default one for the documentation.
|
||||||
|
#
|
||||||
|
# This is mandatory as some option declaration might use the
|
||||||
|
# "name" attribute given as argument of the submodule and use it
|
||||||
|
# as the default of option declarations.
|
||||||
|
args.name = "<name>";
|
||||||
|
}).options;
|
||||||
|
getSubModules = opts';
|
||||||
|
substSubModules = m: submodule m;
|
||||||
|
functor = (defaultFunctor name) // {
|
||||||
|
# Merging of submodules is done as part of mergeOptionDecls, as we have to annotate
|
||||||
|
# each submodule with its location.
|
||||||
|
payload = [];
|
||||||
|
binOp = lhs: rhs: [];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
mkModuleOptions = moduleDefinition: module:
|
mkModuleOptions = moduleDefinition: module:
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
_file = "${module.name}";
|
_file = "${module.name}";
|
||||||
_module.args.k8s = k8s;
|
_module.args.k8s = k8s;
|
||||||
|
_module.args.name = module.name;
|
||||||
}
|
}
|
||||||
(import ./kubernetes.nix {
|
(import ./kubernetes.nix {
|
||||||
customResourceDefinitions =
|
customResourceDefinitions =
|
||||||
|
|
@ -87,7 +128,7 @@ in {
|
||||||
|
|
||||||
configuration = mkOption {
|
configuration = mkOption {
|
||||||
description = "Module configuration";
|
description = "Module configuration";
|
||||||
type = types.submodule {
|
type = submodule {
|
||||||
imports = mkModuleOptions globalConfig.kubernetes.moduleDefinitions.${config.module} config;
|
imports = mkModuleOptions globalConfig.kubernetes.moduleDefinitions.${config.module} config;
|
||||||
};
|
};
|
||||||
default = {};
|
default = {};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue