forked from fediversity/fediversity
Compare commits
5 commits
a8e56f0456
...
f76485819d
| Author | SHA1 | Date | |
|---|---|---|---|
| f76485819d | |||
| 3d94b227d7 | |||
| 10a2d29e54 | |||
| d429c32df0 | |||
| 05b2d41791 |
2 changed files with 42 additions and 54 deletions
|
|
@ -118,7 +118,7 @@ in
|
||||||
enable = lib.mkEnableOption "Hello in the shell";
|
enable = lib.mkEnableOption "Hello in the shell";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
implementation =
|
resources =
|
||||||
cfg:
|
cfg:
|
||||||
lib.optionalAttrs cfg.enable {
|
lib.optionalAttrs cfg.enable {
|
||||||
_class = "fediversity-application-requirements";
|
_class = "fediversity-application-requirements";
|
||||||
|
|
|
||||||
|
|
@ -26,10 +26,40 @@ let
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
nixops4Deployment = import ./deployment.nix { inherit lib inputs; };
|
nixops4Deployment = import ./deployment.nix { inherit lib inputs; };
|
||||||
|
|
||||||
|
configuration = mkOption {
|
||||||
|
description = "Configuration type declaring options to be set by operators";
|
||||||
|
type = optionType;
|
||||||
|
readOnly = true;
|
||||||
|
default = submoduleWith {
|
||||||
|
class = "fediversity-configuration";
|
||||||
|
modules = [
|
||||||
|
{
|
||||||
|
options = {
|
||||||
|
enable = lib.mkEnableOption {
|
||||||
|
description = "your Fediversity configuration";
|
||||||
|
};
|
||||||
|
applications = lib.mapAttrs (
|
||||||
|
_name: application:
|
||||||
|
mkOption {
|
||||||
|
description = application.description;
|
||||||
|
type = submoduleWith {
|
||||||
|
class = "fediversity-application-config";
|
||||||
|
modules = [ application.module ];
|
||||||
|
};
|
||||||
|
default = { };
|
||||||
|
}
|
||||||
|
) config.applications;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
_class = "fediversity-settings";
|
_class = "fediversity-settings";
|
||||||
options = {
|
options = {
|
||||||
|
inherit configuration;
|
||||||
resources = mkOption {
|
resources = mkOption {
|
||||||
description = "Collection of deployment resources that can be required by applications and policed by hosting providers";
|
description = "Collection of deployment resources that can be required by applications and policed by hosting providers";
|
||||||
type = attrsOf (submoduleWith {
|
type = attrsOf (submoduleWith {
|
||||||
|
|
@ -55,6 +85,7 @@ in
|
||||||
{
|
{
|
||||||
options.apply = mkOption {
|
options.apply = mkOption {
|
||||||
description = "Apply the policy to a request";
|
description = "Apply the policy to a request";
|
||||||
|
type = optionType;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
@ -71,7 +102,7 @@ in
|
||||||
type = attrsOf (submoduleWith {
|
type = attrsOf (submoduleWith {
|
||||||
class = "fediversity-application";
|
class = "fediversity-application";
|
||||||
modules = [
|
modules = [
|
||||||
(application: {
|
{
|
||||||
options = {
|
options = {
|
||||||
description = mkOption {
|
description = mkOption {
|
||||||
description = "Description to be shown in the application overview";
|
description = "Description to be shown in the application overview";
|
||||||
|
|
@ -81,30 +112,12 @@ in
|
||||||
description = "Operator-facing configuration options for the application";
|
description = "Operator-facing configuration options for the application";
|
||||||
type = deferredModuleWith { staticModules = [ { _class = "fediversity-application-config"; } ]; };
|
type = deferredModuleWith { staticModules = [ { _class = "fediversity-application-config"; } ]; };
|
||||||
};
|
};
|
||||||
implementation = mkOption {
|
|
||||||
description = "Mapping of application configuration to deployment resources, a description of what an application needs to run";
|
|
||||||
type = application.config.config-mapping.function-type;
|
|
||||||
};
|
|
||||||
resources = mkOption {
|
resources = mkOption {
|
||||||
description = "Compute resources required by an application";
|
description = "Mapping of application configuration to deployment resources, a description of what an application needs to run";
|
||||||
type = functionTo application.config.config-mapping.output-type;
|
type = functionTo (types.submodule application-requirements);
|
||||||
readOnly = true;
|
|
||||||
default = input: (application.config.implementation input).output;
|
|
||||||
};
|
|
||||||
config-mapping = mkOption {
|
|
||||||
description = "Function type for the mapping from application configuration to required resources";
|
|
||||||
type = submoduleWith {
|
|
||||||
class = "module-function";
|
|
||||||
modules = [ functionType ];
|
|
||||||
};
|
|
||||||
readOnly = true;
|
|
||||||
default = {
|
|
||||||
input-type = application.config.module;
|
|
||||||
output-type = application-requirements;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
})
|
}
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
@ -138,7 +151,10 @@ in
|
||||||
};
|
};
|
||||||
implementation = mkOption {
|
implementation = mkOption {
|
||||||
description = "Mapping of resources required by applications to available resources; the result can be deployed";
|
description = "Mapping of resources required by applications to available resources; the result can be deployed";
|
||||||
type = environment.config.resource-mapping.function-type;
|
type = functionTo (submoduleWith {
|
||||||
|
class = "nixops4Deployment";
|
||||||
|
modules = [ environment.config.resource-mapping.output-type ];
|
||||||
|
});
|
||||||
};
|
};
|
||||||
resource-mapping = mkOption {
|
resource-mapping = mkOption {
|
||||||
description = "Function type for the mapping from resources to a (NixOps4) deployment";
|
description = "Function type for the mapping from resources to a (NixOps4) deployment";
|
||||||
|
|
@ -148,7 +164,7 @@ in
|
||||||
};
|
};
|
||||||
readOnly = true;
|
readOnly = true;
|
||||||
default = {
|
default = {
|
||||||
input-type = application-requirements;
|
input-type = configuration;
|
||||||
output-type = nixops4Deployment;
|
output-type = nixops4Deployment;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
@ -167,7 +183,7 @@ in
|
||||||
name: application-settings: config.applications.${name}.resources application-settings
|
name: application-settings: config.applications.${name}.resources application-settings
|
||||||
) cfg.applications;
|
) cfg.applications;
|
||||||
in
|
in
|
||||||
(environment.config.implementation required-resources).output;
|
(environment.config.implementation required-resources);
|
||||||
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
@ -175,33 +191,5 @@ in
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
configuration = mkOption {
|
|
||||||
description = "Configuration type declaring options to be set by operators";
|
|
||||||
type = optionType;
|
|
||||||
readOnly = true;
|
|
||||||
default = submoduleWith {
|
|
||||||
class = "fediversity-configuration";
|
|
||||||
modules = [
|
|
||||||
{
|
|
||||||
options = {
|
|
||||||
enable = lib.mkEnableOption {
|
|
||||||
description = "your Fediversity configuration";
|
|
||||||
};
|
|
||||||
applications = lib.mapAttrs (
|
|
||||||
_name: application:
|
|
||||||
mkOption {
|
|
||||||
description = application.description;
|
|
||||||
type = submoduleWith {
|
|
||||||
class = "fediversity-application-config";
|
|
||||||
modules = [ application.module ];
|
|
||||||
};
|
|
||||||
default = { };
|
|
||||||
}
|
|
||||||
) config.applications;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue