forked from fediversity/fediversity
Compare commits
76 commits
95313c0031
...
0560135cee
| Author | SHA1 | Date | |
|---|---|---|---|
| 0560135cee | |||
| 502cbe8d6d | |||
| 71ebf2e900 | |||
| fadf869ab2 | |||
| 0f1859e15b | |||
| b35e531f47 | |||
| d678ec85f1 | |||
| 38795e1abd | |||
| c20220f6c1 | |||
| 1bf28297c7 | |||
| 81b156f0af | |||
| ce0f00562a | |||
| e7422808f8 | |||
| 88d813f126 | |||
| 11e3c6794a | |||
| 41c5e79e1f | |||
| 1b8b1c60a6 | |||
| cfd3095488 | |||
| 0a8b357051 | |||
| 1d4c40de8a | |||
| d2d1c86b00 | |||
| f6a4838c9d | |||
| d39cecdd41 | |||
| 7f6aa72608 | |||
| 2b4f9cbd19 | |||
| 4818d44051 | |||
| a3fe1c2a8d | |||
| 2505b1f851 | |||
| e7f5714495 | |||
| 828fe084bd | |||
| 234739ce27 | |||
| 5be47c82b4 | |||
| 5e370afd0e | |||
| c486c3e6ed | |||
| a548ef56e6 | |||
| 1cbf286555 | |||
| cfd603f192 | |||
| 5f909a2638 | |||
| c0d5e13aa6 | |||
| 9b87c5b89d | |||
| 193d55b48b | |||
| 2bf2fe32a7 | |||
| ac5f01a66a | |||
| 5b4b674773 | |||
| f2d386e4d3 | |||
| efa11adfdb | |||
| 3e9cf8a879 | |||
| ee393e8610 | |||
| db732a6344 | |||
| bd3b1c2e32 | |||
| 8dd39f05d0 | |||
| b5496b2be1 | |||
| 15a7fe0c67 | |||
| 989dd1db51 | |||
| 05bb9ce9fc | |||
| d9d8fe3025 | |||
| 567b2fd0b7 | |||
| dc6478844a | |||
| a16615e4e3 | |||
| 9dc5069c9d | |||
| 8dfb10520e | |||
| 52b9d730b8 | |||
| a0c1a86129 | |||
| 431966aede | |||
| d8cd1f9473 | |||
| fdadbcc9c3 | |||
| 8d17c84867 | |||
| fb2b79da88 | |||
| d8fcae0ee9 | |||
| ae958ce407 | |||
| f429ed3656 | |||
| 843f4fe4ec | |||
| 09db4d6217 | |||
| c3027eb7d1 | |||
| 4049ca8156 | |||
| 40e8a0a3c5 |
5 changed files with 72 additions and 32 deletions
|
|
@ -1,4 +1,5 @@
|
||||||
on:
|
on:
|
||||||
|
workflow_dispatch: # allows manual triggering
|
||||||
pull_request:
|
pull_request:
|
||||||
types:
|
types:
|
||||||
- opened
|
- opened
|
||||||
|
|
|
||||||
|
|
@ -105,8 +105,7 @@ let
|
||||||
options.enable = lib.mkEnableOption "Hello in the shell";
|
options.enable = lib.mkEnableOption "Hello in the shell";
|
||||||
};
|
};
|
||||||
implementation = cfg: {
|
implementation = cfg: {
|
||||||
input = cfg;
|
resources = lib.optionalAttrs cfg.enable {
|
||||||
output.resources = lib.optionalAttrs cfg.enable {
|
|
||||||
hello.login-shell.packages.hello = pkgs.hello;
|
hello.login-shell.packages.hello = pkgs.hello;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
@ -142,8 +141,7 @@ let
|
||||||
deployment-name,
|
deployment-name,
|
||||||
}:
|
}:
|
||||||
{
|
{
|
||||||
input = required-resources;
|
ssh-host = {
|
||||||
output.ssh-host = {
|
|
||||||
nixos-configuration = mkNixosConfiguration environment required-resources;
|
nixos-configuration = mkNixosConfiguration environment required-resources;
|
||||||
system = targetSystem;
|
system = targetSystem;
|
||||||
ssh = {
|
ssh = {
|
||||||
|
|
@ -166,8 +164,7 @@ let
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
{
|
{
|
||||||
input = required-resources;
|
nixops4 =
|
||||||
output.nixops4 =
|
|
||||||
{ providers, ... }:
|
{ providers, ... }:
|
||||||
{
|
{
|
||||||
providers = {
|
providers = {
|
||||||
|
|
|
||||||
|
|
@ -98,9 +98,9 @@ in
|
||||||
{
|
{
|
||||||
options.enable = lib.mkEnableOption "Hello in the shell";
|
options.enable = lib.mkEnableOption "Hello in the shell";
|
||||||
};
|
};
|
||||||
implementation = cfg: {
|
implementation =
|
||||||
input = cfg;
|
cfg: {
|
||||||
output.resources = lib.optionalAttrs cfg.enable {
|
resources = lib.optionalAttrs cfg.enable {
|
||||||
hello.login-shell.packages.hello = pkgs.hello;
|
hello.login-shell.packages.hello = pkgs.hello;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
@ -110,8 +110,7 @@ in
|
||||||
{
|
{
|
||||||
resources."operator-environment".login-shell.username = "operator";
|
resources."operator-environment".login-shell.username = "operator";
|
||||||
implementation = requests: {
|
implementation = requests: {
|
||||||
input = requests;
|
nixops4 = (
|
||||||
output.nixops4 =
|
|
||||||
{ providers, ... }:
|
{ providers, ... }:
|
||||||
{
|
{
|
||||||
providers = {
|
providers = {
|
||||||
|
|
@ -134,7 +133,8 @@ in
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ let
|
||||||
lib.strings.toJSON v
|
lib.strings.toJSON v
|
||||||
);
|
);
|
||||||
|
|
||||||
functionType = import ./function.nix;
|
functionType = submodule ./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
|
||||||
|
|
@ -223,18 +223,19 @@ in
|
||||||
};
|
};
|
||||||
resources = mkOption {
|
resources = mkOption {
|
||||||
description = "Compute resources required by an application";
|
description = "Compute resources required by an application";
|
||||||
type = functionTo application.config.config-mapping.output-type;
|
type = application.config.config-mapping.function-type;
|
||||||
readOnly = true;
|
readOnly = true;
|
||||||
default = input: (application.config.implementation input).output;
|
default = application.config.config-mapping.apply;
|
||||||
};
|
};
|
||||||
# TODO(@fricklerhandwerk): this needs a better name, it's just the type
|
# TODO(@fricklerhandwerk): this needs a better name
|
||||||
config-mapping = mkOption {
|
config-mapping = mkOption {
|
||||||
description = "Function type for the mapping from application configuration to required resources";
|
description = "Function type for the mapping from application configuration to required resources";
|
||||||
type = submodule functionType;
|
type = functionType;
|
||||||
readOnly = true;
|
readOnly = true;
|
||||||
default = {
|
default = {
|
||||||
input-type = submodule application.config.module;
|
input-type = submodule application.config.module;
|
||||||
output-type = application-resources;
|
output-type = application-resources;
|
||||||
|
implementation = application.config.implementation;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
@ -266,7 +267,7 @@ in
|
||||||
};
|
};
|
||||||
resource-mapping = mkOption {
|
resource-mapping = mkOption {
|
||||||
description = "Function type for the mapping from resources to a deployment";
|
description = "Function type for the mapping from resources to a deployment";
|
||||||
type = submodule functionType;
|
type = functionType;
|
||||||
readOnly = true;
|
readOnly = true;
|
||||||
default = {
|
default = {
|
||||||
input-type = submodule {
|
input-type = submodule {
|
||||||
|
|
@ -280,6 +281,37 @@ in
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
output-type = deployment-type;
|
output-type = deployment-type;
|
||||||
|
implementation = environment.config.implementation;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
config-mapping = mkOption {
|
||||||
|
description = "Mapping from a configuration to a deployment";
|
||||||
|
type = functionType;
|
||||||
|
readOnly = true;
|
||||||
|
default = {
|
||||||
|
input-type = submodule {
|
||||||
|
options = {
|
||||||
|
deployment-name = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
};
|
||||||
|
configuration = mkOption {
|
||||||
|
type = config.configuration;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
output-type = deployment-type;
|
||||||
|
implementation =
|
||||||
|
{
|
||||||
|
deployment-name,
|
||||||
|
configuration,
|
||||||
|
}:
|
||||||
|
# TODO: check cfg.enable.true
|
||||||
|
let
|
||||||
|
required-resources = lib.mapAttrs (
|
||||||
|
name: application-settings: config.applications.${name}.resources application-settings
|
||||||
|
) configuration.applications;
|
||||||
|
in
|
||||||
|
environment.config.resource-mapping.apply { inherit required-resources deployment-name; };
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
# 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`,
|
||||||
|
|
@ -287,21 +319,9 @@ in
|
||||||
# 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 = environment.config.config-mapping.function-type;
|
||||||
readOnly = true;
|
readOnly = true;
|
||||||
default =
|
default = environment.config.config-mapping.apply;
|
||||||
{
|
|
||||||
deployment-name,
|
|
||||||
configuration,
|
|
||||||
}:
|
|
||||||
# TODO: check cfg.enable.true
|
|
||||||
let
|
|
||||||
required-resources = lib.mapAttrs (
|
|
||||||
name: application-settings: config.applications.${name}.resources application-settings
|
|
||||||
) configuration.applications;
|
|
||||||
in
|
|
||||||
(environment.config.implementation { inherit required-resources deployment-name; }).output;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,11 @@ in
|
||||||
type = optionType;
|
type = optionType;
|
||||||
};
|
};
|
||||||
function-type = mkOption {
|
function-type = mkOption {
|
||||||
|
type = optionType;
|
||||||
|
readOnly = true;
|
||||||
|
default = functionTo config.output-type;
|
||||||
|
};
|
||||||
|
wrapper-type = mkOption {
|
||||||
type = optionType;
|
type = optionType;
|
||||||
readOnly = true;
|
readOnly = true;
|
||||||
default = functionTo (submodule {
|
default = functionTo (submodule {
|
||||||
|
|
@ -32,5 +37,22 @@ in
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
implementation = mkOption {
|
||||||
|
type = config.function-type;
|
||||||
|
default = _: { };
|
||||||
|
};
|
||||||
|
wrapper = mkOption {
|
||||||
|
type = config.wrapper-type;
|
||||||
|
readOnly = true;
|
||||||
|
default = input: fn: {
|
||||||
|
inherit input;
|
||||||
|
output = config.implementation fn.config.input;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
apply = mkOption {
|
||||||
|
type = config.function-type;
|
||||||
|
readOnly = true;
|
||||||
|
default = input: (config.wrapper input).output;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue