forked from fediversity/fediversity
Compare commits
72 commits
0560135cee
...
95313c0031
| Author | SHA1 | Date | |
|---|---|---|---|
| 95313c0031 | |||
| ec28601a41 | |||
| e24171f1d5 | |||
| 6b9a57bd43 | |||
| ca62278582 | |||
| 57b6a590c0 | |||
| b09e72e592 | |||
| b9e058369c | |||
| 5f2accc987 | |||
| 93f17b6a42 | |||
| 78eb747256 | |||
| 17f6d3269b | |||
| ee045f98a1 | |||
| a8bba3e2f7 | |||
| c7e1e0fefa | |||
| 2759757cc4 | |||
| db827dcfab | |||
| 3c7ed1b662 | |||
| de1fbd25fc | |||
| 8679fdf833 | |||
| 9a2f6a6173 | |||
| 48d5b06c16 | |||
| 9871d4d674 | |||
| 77cd156236 | |||
| 0174c583ca | |||
| 4240d974fa | |||
| 22ad5fac8d | |||
| be09ee868a | |||
| 983c557d74 | |||
| fe568085a5 | |||
| ebb5f6962c | |||
| 32d02a7d76 | |||
| d20c2ddfc6 | |||
| e57ef09300 | |||
| 4403e3ff9f | |||
| 5555e14779 | |||
| 9783a461a9 | |||
| 6e01c454a4 | |||
| a87fee4055 | |||
| 1b5ac64568 | |||
| 3d64683df3 | |||
| 5e1cee9ab3 | |||
| 0a3ac78758 | |||
| a6fa7838b3 | |||
| d872f202fd | |||
| 5a3bbb3f58 | |||
| 7b2fb9fe2a | |||
| a60bc4f6db | |||
| 94a4318f43 | |||
| 6e0627f983 | |||
| 325c228b84 | |||
| 3b514b9960 | |||
| 71ef264ff8 | |||
| bf7aebd852 | |||
| 5bb939d68e | |||
| 81467ba3e5 | |||
| 130ccf78c0 | |||
| a9c6b667fb | |||
| cba3311289 | |||
| 248ba40771 | |||
| e2fc829c66 | |||
| d6e30517ec | |||
| 24d4a7aea7 | |||
| dc0b4caf3b | |||
| 7011b4ff40 | |||
| 329b5b7a22 | |||
| 1d0a696c31 | |||
| 8540773207 | |||
| f71487469b | |||
| 5a23f63939 | |||
| 424b27be3f | |||
| 806f561153 |
5 changed files with 32 additions and 72 deletions
|
|
@ -1,5 +1,4 @@
|
|||
on:
|
||||
workflow_dispatch: # allows manual triggering
|
||||
pull_request:
|
||||
types:
|
||||
- opened
|
||||
|
|
|
|||
|
|
@ -105,7 +105,8 @@ let
|
|||
options.enable = lib.mkEnableOption "Hello in the shell";
|
||||
};
|
||||
implementation = cfg: {
|
||||
resources = lib.optionalAttrs cfg.enable {
|
||||
input = cfg;
|
||||
output.resources = lib.optionalAttrs cfg.enable {
|
||||
hello.login-shell.packages.hello = pkgs.hello;
|
||||
};
|
||||
};
|
||||
|
|
@ -141,7 +142,8 @@ let
|
|||
deployment-name,
|
||||
}:
|
||||
{
|
||||
ssh-host = {
|
||||
input = required-resources;
|
||||
output.ssh-host = {
|
||||
nixos-configuration = mkNixosConfiguration environment required-resources;
|
||||
system = targetSystem;
|
||||
ssh = {
|
||||
|
|
@ -164,7 +166,8 @@ let
|
|||
...
|
||||
}:
|
||||
{
|
||||
nixops4 =
|
||||
input = required-resources;
|
||||
output.nixops4 =
|
||||
{ providers, ... }:
|
||||
{
|
||||
providers = {
|
||||
|
|
|
|||
|
|
@ -98,9 +98,9 @@ in
|
|||
{
|
||||
options.enable = lib.mkEnableOption "Hello in the shell";
|
||||
};
|
||||
implementation =
|
||||
cfg: {
|
||||
resources = lib.optionalAttrs cfg.enable {
|
||||
implementation = cfg: {
|
||||
input = cfg;
|
||||
output.resources = lib.optionalAttrs cfg.enable {
|
||||
hello.login-shell.packages.hello = pkgs.hello;
|
||||
};
|
||||
};
|
||||
|
|
@ -110,7 +110,8 @@ in
|
|||
{
|
||||
resources."operator-environment".login-shell.username = "operator";
|
||||
implementation = requests: {
|
||||
nixops4 = (
|
||||
input = requests;
|
||||
output.nixops4 =
|
||||
{ providers, ... }:
|
||||
{
|
||||
providers = {
|
||||
|
|
@ -133,8 +134,7 @@ in
|
|||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
);
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ let
|
|||
lib.strings.toJSON v
|
||||
);
|
||||
|
||||
functionType = submodule ./function.nix;
|
||||
functionType = import ./function.nix;
|
||||
application-resources = submodule {
|
||||
options.resources = mkOption {
|
||||
# TODO: maybe transpose, and group the resources by type instead
|
||||
|
|
@ -223,19 +223,18 @@ in
|
|||
};
|
||||
resources = mkOption {
|
||||
description = "Compute resources required by an application";
|
||||
type = application.config.config-mapping.function-type;
|
||||
type = functionTo application.config.config-mapping.output-type;
|
||||
readOnly = true;
|
||||
default = application.config.config-mapping.apply;
|
||||
default = input: (application.config.implementation input).output;
|
||||
};
|
||||
# TODO(@fricklerhandwerk): this needs a better name
|
||||
# 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 = functionType;
|
||||
type = submodule functionType;
|
||||
readOnly = true;
|
||||
default = {
|
||||
input-type = submodule application.config.module;
|
||||
output-type = application-resources;
|
||||
implementation = application.config.implementation;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
@ -267,7 +266,7 @@ in
|
|||
};
|
||||
resource-mapping = mkOption {
|
||||
description = "Function type for the mapping from resources to a deployment";
|
||||
type = functionType;
|
||||
type = submodule functionType;
|
||||
readOnly = true;
|
||||
default = {
|
||||
input-type = submodule {
|
||||
|
|
@ -281,37 +280,6 @@ in
|
|||
};
|
||||
};
|
||||
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`,
|
||||
|
|
@ -319,9 +287,21 @@ in
|
|||
# then the deployments can simply be the result of the function application baked into this module.
|
||||
deployment = mkOption {
|
||||
description = "Generate a deployment from a configuration, by applying an environment's resource policies to the applications' resource mappings";
|
||||
type = environment.config.config-mapping.function-type;
|
||||
type = functionTo (environment.config.resource-mapping.output-type);
|
||||
readOnly = true;
|
||||
default = environment.config.config-mapping.apply;
|
||||
default =
|
||||
{
|
||||
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,11 +19,6 @@ in
|
|||
type = optionType;
|
||||
};
|
||||
function-type = mkOption {
|
||||
type = optionType;
|
||||
readOnly = true;
|
||||
default = functionTo config.output-type;
|
||||
};
|
||||
wrapper-type = mkOption {
|
||||
type = optionType;
|
||||
readOnly = true;
|
||||
default = functionTo (submodule {
|
||||
|
|
@ -37,22 +32,5 @@ 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