{ 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 (lib.mapAttrs' (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 (environment: { _class = "fediversity-environment"; options = { resources = mkOption { description = "Resources made available by the hosting provider"; type = attrsOf ( attrTag ( lib.mapAttrs' (name: resource: { ${name} = mkOption { type = resource.provider; }; }) config.resources ) ); }; resource-mapping = mkOption { description = "Mapping of resources required by applications to available resources; the result can be deployed"; # TODO: type = consumer-resources /* same as the output of application.config-mapping, should be in a `let` */ -> nixops4Deployment }; }; }) ); }; }; }