forked from fediversity/fediversity
90 lines
2.9 KiB
Nix
90 lines
2.9 KiB
Nix
{
|
|
lib,
|
|
config,
|
|
...
|
|
}:
|
|
let
|
|
inherit (lib) mkOption;
|
|
inherit (lib.types)
|
|
attrsOf
|
|
attrTag
|
|
deferredModuleWith
|
|
mergeTypes
|
|
nullOr
|
|
submoduleWith
|
|
submodule
|
|
str
|
|
;
|
|
in
|
|
{
|
|
options = {
|
|
resources = mkOption {
|
|
description = "Collection of deployment resources that can be configured by hosting providers and required by applications";
|
|
type = attrsOf (
|
|
submodule (
|
|
{ config, ... }:
|
|
{
|
|
class = "fediversity-resource";
|
|
options = {
|
|
consumer = mkOption {
|
|
description = "Configuration of the resource by an application, a description of how the resource is consumed";
|
|
type = deferredModuleWith { staticModules = [ { class = "fediversity-resource-consumer"; } ]; };
|
|
};
|
|
provider = mkOption {
|
|
description = "Configuration of the resource by the hosting provider, a description of how the resource is made available";
|
|
type = deferredModuleWith { staticModules = [ { class = "fediversity-resource-provider"; } ]; };
|
|
};
|
|
};
|
|
}
|
|
)
|
|
);
|
|
};
|
|
applications = mkOption {
|
|
description = "Collection of Fediversity applications";
|
|
type = attrsOf (
|
|
submodule (application: {
|
|
class = "fediversity-application";
|
|
options = {
|
|
module = mkOption {
|
|
description = "Operator-facing configuration options for the application";
|
|
type = deferredModuleWith { staticModules = [ { class = "fediversity-application-config"; } ]; };
|
|
};
|
|
config-mapping = mkOption {
|
|
description = "Mapping of application configuration to deployment resources, a description of what an application needs to run";
|
|
# TODO: type = (submodule application.config.module) -> (attrsOf (attrTag (map (name: resource: { ${name} = mkOption { type = resource.consumer; }; }) config.resources))) /* something like that */
|
|
};
|
|
};
|
|
})
|
|
);
|
|
};
|
|
environments = mkOption {
|
|
description = "Run-time environments for Fediversity applications to be deployed to";
|
|
type = attrsOf (
|
|
submodule (
|
|
{ config, ... }:
|
|
{
|
|
class = "fediversity-environment";
|
|
options = {
|
|
required-resources = mkOption {
|
|
description = "Resources required by configured applications";
|
|
# TODO: type = ?
|
|
|
|
};
|
|
available-resources = mkOption {
|
|
description = "Resources made available by the hosting provider";
|
|
# TODO: type = ?
|
|
};
|
|
resource-mapping = mkOption {
|
|
description = "Mapping of resources required by applications to available resources";
|
|
# TODO: type = ?
|
|
};
|
|
};
|
|
}
|
|
)
|
|
);
|
|
};
|
|
};
|
|
}
|
|
};
|
|
};
|
|
}
|