remove module functions from application resources

This commit is contained in:
Kiara Grouwstra 2025-08-01 12:49:19 +02:00
parent 9c219341b1
commit 2be6684d68
Signed by: kiara
SSH key fingerprint: SHA256:COspvLoLJ5WC5rFb9ZDe5urVCkK4LJZOsjfF4duRJFU
2 changed files with 21 additions and 39 deletions

View file

@ -99,13 +99,12 @@ in
{ {
options.enable = lib.mkEnableOption "Hello in the shell"; options.enable = lib.mkEnableOption "Hello in the shell";
}; };
implementation = cfg: { implementation =
input = cfg; cfg:
output = lib.optionalAttrs cfg.enable { lib.optionalAttrs cfg.enable {
resources.hello.login-shell.packages.hello = pkgs.hello; resources.hello.login-shell.packages.hello = pkgs.hello;
}; };
}; };
};
environments.single-nixos-vm = environments.single-nixos-vm =
{ config, ... }: { config, ... }:
{ {
@ -152,7 +151,7 @@ in
}; };
} }
); );
resources = fediversity.applications.hello.resources fediversity.example-configuration.applications.hello; resources = fediversity.applications.hello.implementation fediversity.example-configuration.applications.hello;
hello-shell = resources.resources.hello.login-shell; hello-shell = resources.resources.hello.login-shell;
environment = fediversity.environments.single-nixos-vm.resources.operator-environment.login-shell; environment = fediversity.environments.single-nixos-vm.resources.operator-environment.login-shell;
result = mkDeployment { result = mkDeployment {

View file

@ -85,8 +85,7 @@ in
}; };
applications = mkOption { applications = mkOption {
description = "Collection of Fediversity applications"; description = "Collection of Fediversity applications";
type = attrsOf ( type = attrsOf (submodule {
submodule (application: {
_class = "fediversity-application"; _class = "fediversity-application";
options = { options = {
description = mkOption { description = mkOption {
@ -98,28 +97,12 @@ in
type = deferredModuleWith { staticModules = [ { _class = "fediversity-application-config"; } ]; }; type = deferredModuleWith { staticModules = [ { _class = "fediversity-application-config"; } ]; };
}; };
implementation = mkOption { implementation = mkOption {
description = "Mapping of application configuration to deployment resources, a description of what an application needs to run"; description = "Mapping of application configuration to deployment resources required by an application";
type = application.config.config-mapping.function-type; # input: submodule application.config.module
}; type = functionTo application-resources;
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;
};
# TODO(@fricklerhandwerk): this needs a better name, it's just the type
config-mapping = mkOption {
description = "Function type for the mapping from application configuration to required resources";
type = submodule functionType;
readOnly = true;
default = {
input-type = submodule application.config.module;
output-type = application-resources;
}; };
}; };
}; });
})
);
}; };
environments = mkOption { environments = mkOption {
description = "Run-time environments for Fediversity applications to be deployed to"; description = "Run-time environments for Fediversity applications to be deployed to";