From 1d7a18b0a643b963af25c747eaa5700a4e53feed Mon Sep 17 00:00:00 2001 From: Valentin Gagarin Date: Tue, 1 Jul 2025 12:16:29 +0200 Subject: [PATCH] WIP --- deployment/data-model.nix | 116 ++++++++++---------------------------- 1 file changed, 30 insertions(+), 86 deletions(-) diff --git a/deployment/data-model.nix b/deployment/data-model.nix index 2a52728c..19d2af1d 100644 --- a/deployment/data-model.nix +++ b/deployment/data-model.nix @@ -20,101 +20,45 @@ let submodule str ; - provider = mkOption { - description = "The NixOS module of a provider"; - type = deferredModule; - default = { - _class = "nixos"; - }; - }; - runtime-environment = attrTag ( - mapAttrs - ( - name: - option@{ type, ... }: - mkOption ( - option - // { - type = mergeTypes type (submodule { - options.module = mkOption { - description = "The NixOS module of the provider"; - type = deferredModule; - default = config.providers.${name}; - readOnly = true; - }; - }); - } - ) - ) - { - vm = { - description = "A VM to deploy to."; - type = submodule { - options = { - }; - }; - }; - single-ssh-host = { - description = "A single host to deploy to by SSH."; - type = submodule { - options = { - ssh = mkOption { - description = "SSH connection info"; - type = submodule { - options = { - host = mkOption { - description = "the host to access by SSH"; - type = str; - }; - username = mkOption { - description = "the SSH user to use"; - type = nullOr str; - default = null; - }; - authentication = mkOption { - description = "authentication method"; - type = attrsOf (attrTag { - private-key = mkOption { - description = "path to the user's SSH private key"; - type = str; - example = "/root/.ssh/id_ed25519"; - }; - password = mkOption { - description = "SSH password"; - # TODO: mark as sensitive - type = str; - }; - }); - }; - }; - }; - }; - }; - }; - }; - } - ); - resource = attrTag { - runtime-environment = mkOption { - description = "A run-time environment one may deploy a NixOS configuration to."; - type = runtime-environment; - }; - }; - application = submoduleWith { - description = "A Fediversity application"; + resource = submoduleWith { + description = "A deployment resource that can be configured by providers and required by applications"; modules = [ { options = { - module = mkOption { - description = '' - The NixOS module to configure the application. - ''; + 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 = [