forked from fediversity/fediversity
Compare commits
No commits in common. "f76485819d5933cb1d22738f6fc599b682542edf" and "a8e56f0456268509671d9f7aac0e4a733c03af9b" have entirely different histories.
f76485819d
...
a8e56f0456
2 changed files with 54 additions and 42 deletions
|
|
@ -118,7 +118,7 @@ in
|
||||||
enable = lib.mkEnableOption "Hello in the shell";
|
enable = lib.mkEnableOption "Hello in the shell";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
resources =
|
implementation =
|
||||||
cfg:
|
cfg:
|
||||||
lib.optionalAttrs cfg.enable {
|
lib.optionalAttrs cfg.enable {
|
||||||
_class = "fediversity-application-requirements";
|
_class = "fediversity-application-requirements";
|
||||||
|
|
|
||||||
|
|
@ -26,40 +26,10 @@ 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 {
|
||||||
|
|
@ -85,7 +55,6 @@ in
|
||||||
{
|
{
|
||||||
options.apply = mkOption {
|
options.apply = mkOption {
|
||||||
description = "Apply the policy to a request";
|
description = "Apply the policy to a request";
|
||||||
type = optionType;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
@ -102,7 +71,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";
|
||||||
|
|
@ -112,12 +81,30 @@ 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"; } ]; };
|
||||||
};
|
};
|
||||||
resources = mkOption {
|
implementation = mkOption {
|
||||||
description = "Mapping of application configuration to deployment resources, a description of what an application needs to run";
|
description = "Mapping of application configuration to deployment resources, a description of what an application needs to run";
|
||||||
type = functionTo (types.submodule application-requirements);
|
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;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
})
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
@ -151,10 +138,7 @@ 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 = functionTo (submoduleWith {
|
type = environment.config.resource-mapping.function-type;
|
||||||
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";
|
||||||
|
|
@ -164,7 +148,7 @@ in
|
||||||
};
|
};
|
||||||
readOnly = true;
|
readOnly = true;
|
||||||
default = {
|
default = {
|
||||||
input-type = configuration;
|
input-type = application-requirements;
|
||||||
output-type = nixops4Deployment;
|
output-type = nixops4Deployment;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
@ -183,7 +167,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);
|
(environment.config.implementation required-resources).output;
|
||||||
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
@ -191,5 +175,33 @@ 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