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