diff --git a/deployment/data-model-test.nix b/deployment/data-model-test.nix index dcaf8a41..4db7d9af 100644 --- a/deployment/data-model-test.nix +++ b/deployment/data-model-test.nix @@ -37,13 +37,20 @@ in applications.foo.module = { pkgs, ... }: { - environment.systemPackages = [ + options.doll = lib.mkOption { + type = lib.types.str; + }; + config.environment.systemPackages = [ pkgs.hello ]; }; deployments.baz = { - module = { }; inherit runtime-environment; + application-configuration = { + foo = { + doll = 123; + }; + }; }; migrations.boo = { inherit runtime-environment; @@ -56,7 +63,7 @@ in has-provider = lib.isAttrs example.providers.ssh-host; has-resource = lib.isAttrs example.resources.bar.runtime-environment.ssh-host.module; has-application = lib.isAttrs example.applications.foo.module; - has-deployment = lib.isAttrs example.deployments.baz.module; + has-deployment = lib.isAttrs example.deployments.baz.application-configuration.foo.doll; has-migration = lib.isAttrs example.migrations.boo.deployment; }; expected = { diff --git a/deployment/data-model.nix b/deployment/data-model.nix index 502071e1..71dba8ad 100644 --- a/deployment/data-model.nix +++ b/deployment/data-model.nix @@ -120,12 +120,47 @@ let modules = [ { options = { - # the `applications` option consists of configuration for the above applications - module = mkOption { + application-configuration = mkOption { description = '' Configuration to be deployed ''; - type = deferredModule; + # # error: attribute 'foo' missing + # type = deferredModule; + # type = submodule { + # # # checks types but is hard-coded + # # options = { + # # foo = mkOption { + # # # type = str; + # # type = submodule { + # # options = { + # # doll = mkOption { + # # type = str; + # # }; + # # }; + # # }; + # # }; + # # }; + # # # `error: attribute 'doll' missing` in `example.deployments.baz.application-configuration.doll` + # # freeformType = attrsOf deferredModule; + # # options = mapAttrs + # # (k: application: mkOption { + # # description = "configuration options for ${k}"; + # # # # error: attribute 'doll' missing + # # # type = deferredModule; + # # # # XXX doesn't work as `import` is for paths + # # # type = submodule { inherit (import application.module { }) options; }; + # # # # XXX doesn't work as `evalModules` is general, not recognizing nixos stuff like argument `pkgs` or `config.environment` + # # # type = submodule { + # # # inherit (lib.evalModules { modules = [ application.module ]; }) options; + # # # }; + # # # # error: The option `deployments.baz.application-configuration.foo._module.freeformType' in `lib/modules.nix' is already declared in `data-model.nix'. + # # # # n.b. `_module.freeformType` is an option set in `evalModules`. + # # # type = submodule { + # # # inherit (import "${sources.nixpkgs}/nixos" { configuration = application.module; }) options; + # # # }; + # # }) + # # (removeAttrs (config.applications) [ "_module" ]); + # }; }; runtime-environment = mkOption { description = "The run-time environment to deploy to";