diff --git a/deployment/data-model-test.nix b/deployment/data-model-test.nix index 3f24df94..92b20d88 100644 --- a/deployment/data-model-test.nix +++ b/deployment/data-model-test.nix @@ -17,52 +17,29 @@ in test-eval = { expr = let - example = eval ( + fediversity = eval ( { config, ... }: { - providers.single-ssh-host = - { ... }: - { - system.stateVersion = "25.05"; - }; - resources.bar.runtime-environment.single-ssh-host = { - ssh = { - host = "localhost"; - username = "root"; - authentication.password = ""; - }; + resources.nixos = { + }; - applications.foo.module = - { pkgs, ... }: - { - environment.systemPackages = [ - pkgs.hello - ]; - }; - deployments.baz = { - module = { }; - runtime-environment = config.resources.bar.runtime-environment; + applications.hello = { + }; - migrations.boo = { - deployment = config.deployments.baz; - runtime-environment = config.resources.bar.runtime-environment; + environments.single-nixos-vm = { + + }; + configurations.example = { + enable = true; + applications.hello.enable = true; }; } ); in { - has-provider = lib.isAttrs example.providers.single-ssh-host; - has-resource = lib.isAttrs example.resources.bar.runtime-environment.single-ssh-host.module; - has-application = lib.isAttrs example.applications.foo.module; - has-deployment = lib.isAttrs example.deployments.baz.module; - has-migration = lib.isAttrs example.migrations.boo.deployment; + }; expected = { - has-provider = true; - has-resource = true; - has-application = true; - has-deployment = true; - has-migration = true; }; }; } diff --git a/deployment/data-model.nix b/deployment/data-model.nix index af6eda78..82a1e165 100644 --- a/deployment/data-model.nix +++ b/deployment/data-model.nix @@ -5,16 +5,13 @@ ... }: let - inherit (lib) mkOption; + inherit (lib) mkOption types; inherit (lib.types) attrsOf attrTag deferredModuleWith - mergeTypes - nullOr submoduleWith submodule - str ; functionType = import ./interface.nix; @@ -70,7 +67,7 @@ in }; # TODO: somewhere we still need to # - apply = { implementation = config-mapping; input = ; } - # - apply.output + # - apply.output (applications required by resources) function = mkOption { description = "Function type for the mapping from application configuration to required resources"; type = submodule functionType; @@ -103,8 +100,10 @@ in resource-mapping = mkOption { description = "Mapping of resources required by applications to available resources; the result can be deployed"; type = environment.config.function.implementation; - # TODO: type = consumer-resources /* same as the output of application.config-mapping, should be in a `let` */ -> nixops4Deployment }; + # TODO: somewhere we still need to + # - apply = { implementation = resource-mapping; input = ; } + # - apply.output (deployment) function = mkOption { description = "Function type for the mapping from resources to a (NixOps4) deployment"; type = submodule functionType; @@ -118,5 +117,17 @@ in }) ); }; + configurations = mkOption { + description = "Application configurations set by operators"; + type = attrsOf (submodule { + options = { + enable = mkOption { + description = "Whether to enable the configuration"; + type = types.bool; + }; + applications = mapAttrs (name: application: submodule application.module) config.applications; + }; + }); + }; }; }