From 7880e7e6a0ade09937d5e930de6f3b41add73f26 Mon Sep 17 00:00:00 2001 From: Valentin Gagarin Date: Tue, 1 Jul 2025 17:52:37 +0200 Subject: [PATCH] WIP --- deployment/data-model.nix | 43 +++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/deployment/data-model.nix b/deployment/data-model.nix index a2bcc711..bc171656 100644 --- a/deployment/data-model.nix +++ b/deployment/data-model.nix @@ -51,7 +51,7 @@ in }; 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 */ + # TODO: type = (submodule application.config.module) -> (attrsOf (attrTag (lib.mapAttrs' (name: resource: { ${name} = mkOption { type = resource.consumer; }; }) config.resources))) /* something like that */ }; }; }) @@ -60,31 +60,26 @@ in 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 = ? - }; + 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 + }; + }; + }) ); }; }; -} - }; - }; }