diff --git a/deployment/data-model.nix b/deployment/data-model.nix index 19d2af1d..8fb9a250 100644 --- a/deployment/data-model.nix +++ b/deployment/data-model.nix @@ -4,12 +4,7 @@ ... }: let - inherit (lib) - attrNames - mapAttrs - mkOption - genAttrs - ; + inherit (lib) mkOption; inherit (lib.types) attrsOf attrTag @@ -20,104 +15,68 @@ let submodule str ; - resource = submoduleWith { - description = "A deployment resource that can be configured by providers and required by applications"; - modules = [ - { - options = { - consumer = mkOption { - description = "Description how applications can consume the resource"; - type = deferredModule; - }; - provider = mkOption { - description = "Description how the hosting provider makes the resource available"; - type = deferredModule; - }; - }; - } - ]; - }; - application = submoduleWith { - description = "A Fediversity application"; - modules = [ - ( - { config, ... }: - { - options = { - module = mkOption { - description = '' - A module for configuring the application. - ''; - type = deferredModule; - }; - config-mapping = mkOption { - description = "description of how an application configuration maps to deployment resources"; - # TODO: type = (submodule config.module) -> (attrsOf resource) - }; - }; - } - ) - ]; - }; - deployment = submoduleWith { - description = "A deployment of a configuration of applications to a run-time environment"; - modules = [ - { - options = { - # the `applications` option consists of configuration for the above applications - module = mkOption { - description = '' - Configuration to be deployed - ''; - type = deferredModule; - }; - runtime-environment = mkOption { - description = "The run-time environment to deploy to"; - type = runtime-environment; - }; - }; - } - ]; - }; - migration = submoduleWith { - description = "Migration of a Fediversity deployment to a Fediversity run-time environment"; - modules = [ - { - options = { - deployment = mkOption { - description = "Deployment to migrate"; - type = deployment; - }; - runtime-environment = mkOption { - description = "Run-time environment to migrate the deployment to"; - type = runtime-environment; - }; - }; - } - ]; - }; in { options = { - providers = mkOption { - description = "Collection of providers for run-time environments to deploy applications to"; - type = attrTag (genAttrs (attrNames runtime-environment.nestedTypes) (_: provider)); - }; resources = mkOption { - description = "Collection of resources for use in Fediversity applications"; - type = attrsOf resource; + description = "Collection of deployment resources that can be configured by hosting providers and required by applications"; + type = attrsOf (submodule { + options = { + consumer = mkOption { + description = "Configuration of the resource by an application, a description of how the resource is consumed"; + type = deferredModule; + }; + provider = mkOption { + description = "Configuration of the resource by the hosting provider, a description of how the resource is made available"; + type = deferredModule; + }; + }; + }); }; applications = mkOption { - description = "Collection of (available) Fediversity applications"; - type = attrsOf application; + description = "Collection of Fediversity applications"; + type = attrsOf ( + submodule ( + { config, ... }: + { + options = { + module = mkOption { + description = "Operator-facing configuration options for the application"; + type = deferredModule; + }; + config-mapping = mkOption { + description = "Mapping of application configuration to deployment resources, a description of what an application needs to run"; + # TODO: type = (submodule config.module) -> (attrsOf resource) + }; + }; + } + ) + ); }; - deployments = mkOption { - description = "Deployment of a configuration of applications to a run-time environment"; - type = attrsOf deployment; - }; - migrations = mkOption { - description = "Migrations from Fediversity deployments to Fediversity run-time environments"; - type = attrsOf migration; + environments = mkOption { + description = "Run-time environments for Fediversity applications to be deployed to"; + type = attrsOf ( + submodule ( + { config, ... }: + { + 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 = ? + }; + }; + } + ) + ); }; }; }