diff --git a/default.nix b/default.nix index 24b73cd2..a4cea1a3 100644 --- a/default.nix +++ b/default.nix @@ -9,6 +9,8 @@ let git-hooks gitignore ; + inherit (import sources.flake-inputs) import-flake; + inputs = (import-flake { src = ./.; }).inputs; inherit (pkgs) lib; inherit (import sources.flake-inputs) import-flake; inherit ((import-flake { src = ./.; }).inputs) nixops4; @@ -78,6 +80,7 @@ in # re-export inputs so they can be overridden granularly # (they can't be accessed from the outside any other way) inherit + inputs sources system pkgs diff --git a/deployment/data-model-test.nix b/deployment/data-model-test.nix index 26340f9d..64cfaf0d 100644 --- a/deployment/data-model-test.nix +++ b/deployment/data-model-test.nix @@ -15,8 +15,6 @@ let }).config; in { - _class = "nix-unit"; - test-eval = { expr = let diff --git a/deployment/data-model.nix b/deployment/data-model.nix index aa425b1a..b6348b03 100644 --- a/deployment/data-model.nix +++ b/deployment/data-model.nix @@ -1,6 +1,7 @@ { lib, config, + inputs, ... }: let @@ -103,8 +104,18 @@ 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 }; + function = mkOption { + description = "Function type for the mapping from resources to a (NixOps4) deployment"; + type = submodule functionType; + readOnly = true; + default = { + input-type = application-resources; + output-type = submodule nixops4Deployment; + }; + }; }; }) ); diff --git a/deployment/interface.nix b/deployment/interface.nix new file mode 100644 index 00000000..225526d1 --- /dev/null +++ b/deployment/interface.nix @@ -0,0 +1,49 @@ +/** + Modular function type +*/ +{ config, ... }: +{ + options = { + input-type = mkOption { + type = deferredModule; + }; + output-type = mkOption { + type = deferredModule; + }; + implementation = mkOption { + type = optionType; + readOnly = true; + default = implementationTo ( + submodule (implementation: { + options = { + input = mkOption { + type = submodule config.input-type; + }; + output = mkOption { + type = submodule config.output-type; + }; + }; + }) + ); + }; + apply = mkOption { + type = optionType; + readOnly = true; + default = submodule (apply: { + options = { + implementation = mkOption { + type = config.implementation; + }; + input = mkOption { + type = submodule config.input-type; + }; + output = mkOption { + type = submodule config.output-type; + readOnly = true; + default = (apply.config.implementation apply.config.input).output; + }; + }; + }); + }; + }; +}