diff --git a/deployment/data-model-test.nix b/deployment/data-model-test.nix index 0deeb563..5e4879d3 100644 --- a/deployment/data-model-test.nix +++ b/deployment/data-model-test.nix @@ -13,6 +13,7 @@ let ./data-model.nix ]; }).config; + nixops4Deployment = inputs.nixops4.modules.nixops4Deployment.default; in { test-eval = { diff --git a/deployment/data-model.nix b/deployment/data-model.nix index de58f351..0d3868ee 100644 --- a/deployment/data-model.nix +++ b/deployment/data-model.nix @@ -102,35 +102,57 @@ in ) ); }; - resource-mapping = mkOption { + implementation = mkOption { description = "Mapping of resources required by applications to available resources; the result can be deployed"; - type = environment.config.function.implementation; + type = environment.config.resource-mapping.function-type; }; - # TODO: somewhere we still need to - # - apply = { implementation = resource-mapping; input = ; } - # - apply.output (deployment) - function = mkOption { + resource-mapping = mkOption { description = "Function type for the mapping from resources to a (NixOps4) deployment"; type = submodule functionType; readOnly = true; default = { input-type = application-resources; - output-type = submodule nixops4Deployment; + output-type = nixops4Deployment; }; }; + deployment = mkOption { + description = "Generate a deployment from a configuration"; + type = functionTo environment.config.resource-mapping.output-type; + readOnly = true; + default = + cfg: + # TODO: check cfg.enable.true + let + required-resources = lib.mapAttrs ( + name: application-settings: config.applications.${name}.resources application-settings + ) cfg.applications; + in + (environment.config.implementation required-resources).output; + + }; }; }) ); }; - configurations = mkOption { - description = "Application configurations set by operators"; - type = attrsOf (submodule { + configuration = mkOption { + description = "Configuration type declaring options to be set by operators"; + type = optionType; + readOnly = true; + default = submodule (configuration: { options = { enable = mkOption { description = "Whether to enable the configuration"; type = types.bool; + default = false; }; - applications = mapAttrs (name: application: submodule application.module) config.applications; + applications = lib.mapAttrs ( + name: application: + mkOption { + description = application.description; + type = submodule application.module; + default = { }; + } + ) config.applications; }; }); }; diff --git a/deployment/interface.nix b/deployment/interface.nix deleted file mode 100644 index 225526d1..00000000 --- a/deployment/interface.nix +++ /dev/null @@ -1,49 +0,0 @@ -/** - Modular function type -*/ -{ config, ... }: -{ - options = { - input-type = mkOption { - type = deferredModule; - }; - output-type = mkOption { - type = deferredModule; - }; - implementation = mkOption { - type = optionType; - readOnly = true; - default = implementationTo ( - submodule (implementation: { - options = { - input = mkOption { - type = submodule config.input-type; - }; - output = mkOption { - type = submodule config.output-type; - }; - }; - }) - ); - }; - apply = mkOption { - type = optionType; - readOnly = true; - default = submodule (apply: { - options = { - implementation = mkOption { - type = config.implementation; - }; - input = mkOption { - type = submodule config.input-type; - }; - output = mkOption { - type = submodule config.output-type; - readOnly = true; - default = (apply.config.implementation apply.config.input).output; - }; - }; - }); - }; - }; -}