forked from fediversity/fediversity
Compare commits
3 commits
9c219341b1
...
e69bb3bccb
| Author | SHA1 | Date | |
|---|---|---|---|
| e69bb3bccb | |||
| 70789547ee | |||
| 2be6684d68 |
3 changed files with 25 additions and 88 deletions
|
|
@ -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 {
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@ let
|
||||||
functionTo
|
functionTo
|
||||||
;
|
;
|
||||||
|
|
||||||
functionType = import ./function.nix;
|
|
||||||
application-resources = submodule {
|
application-resources = submodule {
|
||||||
options.resources = mkOption {
|
options.resources = mkOption {
|
||||||
# TODO: maybe transpose, and group the resources by type instead
|
# TODO: maybe transpose, and group the resources by type instead
|
||||||
|
|
@ -85,8 +84,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 +96,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";
|
||||||
|
|
@ -141,24 +123,16 @@ in
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
implementation = mkOption {
|
implementation = mkOption {
|
||||||
description = "Mapping of resources required by applications to available resources; the result can be deployed";
|
description = "Mapping from resources required by applications to available resources to a deployment";
|
||||||
type = environment.config.resource-mapping.function-type;
|
# input: application-resources
|
||||||
};
|
type = functionTo nixops4Deployment;
|
||||||
resource-mapping = 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 = nixops4Deployment;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
# TODO(@fricklerhandwerk): maybe this should be a separate thing such as `fediversity-setup`,
|
# TODO(@fricklerhandwerk): maybe this should be a separate thing such as `fediversity-setup`,
|
||||||
# which makes explicit which applications and environments are available.
|
# which makes explicit which applications and environments are available.
|
||||||
# then the deployments can simply be the result of the function application baked into this module.
|
# then the deployments can simply be the result of the function application baked into this module.
|
||||||
deployment = mkOption {
|
deployment = mkOption {
|
||||||
description = "Generate a deployment from a configuration, by applying an environment's resource policies to the applications' resource mappings";
|
description = "Generate a deployment from a configuration, by applying an environment's resource policies to the applications' resource mappings";
|
||||||
type = functionTo (environment.config.resource-mapping.output-type);
|
type = functionTo nixops4Deployment;
|
||||||
readOnly = true;
|
readOnly = true;
|
||||||
default =
|
default =
|
||||||
cfg:
|
cfg:
|
||||||
|
|
|
||||||
|
|
@ -1,36 +0,0 @@
|
||||||
/**
|
|
||||||
Modular function type
|
|
||||||
*/
|
|
||||||
{ config, lib, ... }:
|
|
||||||
let
|
|
||||||
inherit (lib) mkOption types;
|
|
||||||
inherit (types)
|
|
||||||
submodule
|
|
||||||
functionTo
|
|
||||||
optionType
|
|
||||||
;
|
|
||||||
in
|
|
||||||
{
|
|
||||||
options = {
|
|
||||||
input-type = mkOption {
|
|
||||||
type = optionType;
|
|
||||||
};
|
|
||||||
output-type = mkOption {
|
|
||||||
type = optionType;
|
|
||||||
};
|
|
||||||
function-type = mkOption {
|
|
||||||
type = optionType;
|
|
||||||
readOnly = true;
|
|
||||||
default = functionTo (submodule {
|
|
||||||
options = {
|
|
||||||
input = mkOption {
|
|
||||||
type = config.input-type;
|
|
||||||
};
|
|
||||||
output = mkOption {
|
|
||||||
type = config.output-type;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
});
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
Loading…
Add table
Reference in a new issue