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";
|
||||
};
|
||||
};
|
||||
implementation =
|
||||
resources =
|
||||
cfg:
|
||||
lib.optionalAttrs cfg.enable {
|
||||
_class = "fediversity-application-requirements";
|
||||
|
|
|
|||
|
|
@ -26,10 +26,40 @@ let
|
|||
};
|
||||
};
|
||||
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
|
||||
{
|
||||
_class = "fediversity-settings";
|
||||
options = {
|
||||
inherit configuration;
|
||||
resources = mkOption {
|
||||
description = "Collection of deployment resources that can be required by applications and policed by hosting providers";
|
||||
type = attrsOf (submoduleWith {
|
||||
|
|
@ -55,6 +85,7 @@ in
|
|||
{
|
||||
options.apply = mkOption {
|
||||
description = "Apply the policy to a request";
|
||||
type = optionType;
|
||||
};
|
||||
}
|
||||
];
|
||||
|
|
@ -71,7 +102,7 @@ in
|
|||
type = attrsOf (submoduleWith {
|
||||
class = "fediversity-application";
|
||||
modules = [
|
||||
(application: {
|
||||
{
|
||||
options = {
|
||||
description = mkOption {
|
||||
description = "Description to be shown in the application overview";
|
||||
|
|
@ -81,30 +112,12 @@ in
|
|||
description = "Operator-facing configuration options for the application";
|
||||
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 {
|
||||
description = "Compute resources required by an application";
|
||||
type = functionTo application.config.config-mapping.output-type;
|
||||
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;
|
||||
};
|
||||
description = "Mapping of application configuration to deployment resources, a description of what an application needs to run";
|
||||
type = functionTo (types.submodule application-requirements);
|
||||
};
|
||||
};
|
||||
})
|
||||
}
|
||||
];
|
||||
});
|
||||
};
|
||||
|
|
@ -138,7 +151,10 @@ in
|
|||
};
|
||||
implementation = mkOption {
|
||||
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 {
|
||||
description = "Function type for the mapping from resources to a (NixOps4) deployment";
|
||||
|
|
@ -148,7 +164,7 @@ in
|
|||
};
|
||||
readOnly = true;
|
||||
default = {
|
||||
input-type = application-requirements;
|
||||
input-type = configuration;
|
||||
output-type = nixops4Deployment;
|
||||
};
|
||||
};
|
||||
|
|
@ -167,7 +183,7 @@ in
|
|||
name: application-settings: config.applications.${name}.resources application-settings
|
||||
) cfg.applications;
|
||||
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