forked from Fediversity/Fediversity
turn function.nix into a reflective type
This commit is contained in:
parent
9c219341b1
commit
2e91782d7e
2 changed files with 29 additions and 26 deletions
|
@ -15,7 +15,7 @@ let
|
|||
functionTo
|
||||
;
|
||||
|
||||
functionType = import ./function.nix;
|
||||
functionType = import ./function.nix { inherit lib; };
|
||||
application-resources = submodule {
|
||||
options.resources = mkOption {
|
||||
# TODO: maybe transpose, and group the resources by type instead
|
||||
|
@ -110,7 +110,7 @@ in
|
|||
# TODO(@fricklerhandwerk): this needs a better name, it's just the type
|
||||
config-mapping = mkOption {
|
||||
description = "Function type for the mapping from application configuration to required resources";
|
||||
type = submodule functionType;
|
||||
type = functionType;
|
||||
readOnly = true;
|
||||
default = {
|
||||
input-type = submodule application.config.module;
|
||||
|
@ -146,7 +146,7 @@ in
|
|||
};
|
||||
resource-mapping = mkOption {
|
||||
description = "Function type for the mapping from resources to a (NixOps4) deployment";
|
||||
type = submodule functionType;
|
||||
type = functionType;
|
||||
readOnly = true;
|
||||
default = {
|
||||
input-type = application-resources;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
Modular function type
|
||||
*/
|
||||
{ config, lib, ... }:
|
||||
{ lib, ... }:
|
||||
let
|
||||
inherit (lib) mkOption types;
|
||||
inherit (types)
|
||||
|
@ -10,27 +10,30 @@ let
|
|||
optionType
|
||||
;
|
||||
in
|
||||
{
|
||||
options = {
|
||||
input-type = mkOption {
|
||||
type = optionType;
|
||||
};
|
||||
output-type = mkOption {
|
||||
type = optionType;
|
||||
};
|
||||
function-type = mkOption {
|
||||
type = optionType;
|
||||
readOnly = true;
|
||||
default = functionTo (submodule {
|
||||
options = {
|
||||
input = mkOption {
|
||||
type = config.input-type;
|
||||
submodule (
|
||||
{ config, ... }:
|
||||
{
|
||||
options = {
|
||||
input-type = mkOption {
|
||||
type = optionType;
|
||||
};
|
||||
output-type = mkOption {
|
||||
type = optionType;
|
||||
};
|
||||
function-type = mkOption {
|
||||
type = optionType;
|
||||
readOnly = true;
|
||||
default = functionTo (submodule {
|
||||
options = {
|
||||
input = mkOption {
|
||||
type = config.input-type;
|
||||
};
|
||||
output = mkOption {
|
||||
type = config.output-type;
|
||||
};
|
||||
};
|
||||
output = mkOption {
|
||||
type = config.output-type;
|
||||
};
|
||||
};
|
||||
});
|
||||
});
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
)
|
||||
|
|
Loading…
Add table
Reference in a new issue