diff --git a/deployment/data-model-test.nix b/deployment/data-model-test.nix index 24d5cd6c..7ce2fce2 100644 --- a/deployment/data-model-test.nix +++ b/deployment/data-model-test.nix @@ -99,40 +99,37 @@ in { options.enable = lib.mkEnableOption "Hello in the shell"; }; - implementation = cfg: { - input = cfg; - output = lib.optionalAttrs cfg.enable { + implementation = + cfg: + lib.optionalAttrs cfg.enable { resources.hello.login-shell.packages.hello = pkgs.hello; }; - }; }; environments.single-nixos-vm = { config, ... }: { resources.operator-environment.login-shell.username = "operator"; - implementation = requests: { - input = requests; - output = - { providers, ... }: - { - providers = { - inherit (inputs.nixops4.modules.nixops4Provider) local; - }; - resources.the-machine = { - type = providers.local.exec; - imports = [ - inputs.nixops4-nixos.modules.nixops4Resource.nixos - ]; - nixos.module = - { ... }: - { - users.users = config.resources.shell.login-shell.apply ( - lib.filterAttrs (_name: value: value ? login-shell) requests - ); - }; - }; + implementation = + requests: + { providers, ... }: + { + providers = { + inherit (inputs.nixops4.modules.nixops4Provider) local; }; - }; + resources.the-machine = { + type = providers.local.exec; + imports = [ + inputs.nixops4-nixos.modules.nixops4Resource.nixos + ]; + nixos.module = + { ... }: + { + users.users = config.resources.shell.login-shell.apply ( + lib.filterAttrs (_name: value: value ? login-shell) requests + ); + }; + }; + }; }; }; options = { diff --git a/deployment/data-model.nix b/deployment/data-model.nix index c3d5d53a..cefa1e4f 100644 --- a/deployment/data-model.nix +++ b/deployment/data-model.nix @@ -99,13 +99,13 @@ in }; implementation = mkOption { description = "Mapping of application configuration to deployment resources, a description of what an application needs to run"; - type = application.config.config-mapping.function-type; + type = application.config.config-mapping.implementation-type; }; resources = mkOption { description = "Compute resources required by an application"; type = functionTo application.config.config-mapping.output-type; readOnly = true; - default = input: (application.config.implementation input).output; + default = application.config.implementation; }; # TODO(@fricklerhandwerk): this needs a better name, it's just the type config-mapping = mkOption { @@ -142,7 +142,7 @@ in }; implementation = mkOption { description = "Mapping of resources required by applications to available resources; the result can be deployed"; - type = environment.config.resource-mapping.function-type; + type = environment.config.resource-mapping.implementation-type; }; resource-mapping = mkOption { description = "Function type for the mapping from resources to a (NixOps4) deployment"; @@ -168,7 +168,7 @@ in name: application-settings: config.applications.${name}.resources application-settings ) cfg.applications; in - (environment.config.implementation required-resources).output; + environment.config.implementation required-resources; }; }; diff --git a/deployment/function.nix b/deployment/function.nix index f0210a34..48ab9abe 100644 --- a/deployment/function.nix +++ b/deployment/function.nix @@ -18,6 +18,11 @@ in output-type = mkOption { type = optionType; }; + implementation-type = mkOption { + type = optionType; + readOnly = true; + default = functionTo config.output-type; + }; function-type = mkOption { type = optionType; readOnly = true;