forked from Fediversity/Fediversity
move applications
from config
to options
to actually type-check application configurations
This commit is contained in:
parent
dbd3e90238
commit
1d519dceab
4 changed files with 47 additions and 33 deletions
19
deployment/applications/default.nix
Normal file
19
deployment/applications/default.nix
Normal file
|
@ -0,0 +1,19 @@
|
|||
{
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
let
|
||||
applications = [
|
||||
"mastodon"
|
||||
];
|
||||
in
|
||||
{
|
||||
options = lib.genAttrs applications (
|
||||
k:
|
||||
# TODO: how to type entries here to conform to some common structure?
|
||||
lib.mkOption {
|
||||
description = "configuration options for ${k}";
|
||||
type = lib.types.submodule ./${k};
|
||||
}
|
||||
);
|
||||
}
|
19
deployment/applications/mastodon/default.nix
Normal file
19
deployment/applications/mastodon/default.nix
Normal file
|
@ -0,0 +1,19 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
{
|
||||
options =
|
||||
{
|
||||
fediversity.domain = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "fediversity.tld";
|
||||
};
|
||||
}
|
||||
// import ../../../services/fediversity/sharedOptions.nix {
|
||||
inherit config lib;
|
||||
serviceName = "mastodon";
|
||||
serviceDocName = "Mastodon";
|
||||
};
|
||||
}
|
|
@ -34,16 +34,13 @@ in
|
|||
authentication.password = "";
|
||||
};
|
||||
};
|
||||
applications.foo.module =
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
environment.systemPackages = [
|
||||
pkgs.hello
|
||||
];
|
||||
};
|
||||
deployments.baz = {
|
||||
module = { };
|
||||
inherit runtime-environment;
|
||||
application-configuration = {
|
||||
mastodon = {
|
||||
enable = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
migrations.boo = {
|
||||
inherit runtime-environment;
|
||||
|
@ -55,14 +52,12 @@ in
|
|||
{
|
||||
has-provider = lib.isAttrs example.providers.ssh-host;
|
||||
has-resource = lib.isAttrs example.resources.bar.runtime-environment.ssh-host.module;
|
||||
has-application = lib.isAttrs example.applications.foo.module;
|
||||
has-deployment = lib.isAttrs example.deployments.baz.module;
|
||||
has-deployment = example.deployments.baz.application-configuration.mastodon.enable == true;
|
||||
has-migration = lib.isAttrs example.migrations.boo.deployment;
|
||||
};
|
||||
expected = {
|
||||
has-provider = true;
|
||||
has-resource = true;
|
||||
has-application = true;
|
||||
has-deployment = true;
|
||||
has-migration = true;
|
||||
};
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
...
|
||||
}:
|
||||
let
|
||||
applications = ./applications; # how to make this configurable?
|
||||
inherit (lib)
|
||||
attrNames
|
||||
mapAttrs
|
||||
|
@ -100,32 +101,16 @@ let
|
|||
type = runtime-environment;
|
||||
};
|
||||
};
|
||||
application = submoduleWith {
|
||||
description = "A Fediversity application";
|
||||
modules = [
|
||||
{
|
||||
options = {
|
||||
module = mkOption {
|
||||
description = ''
|
||||
The NixOS module to configure the application.
|
||||
'';
|
||||
type = deferredModule;
|
||||
};
|
||||
};
|
||||
}
|
||||
];
|
||||
};
|
||||
deployment = submoduleWith {
|
||||
description = "A deployment of a configuration of applications to a run-time environment";
|
||||
modules = [
|
||||
{
|
||||
options = {
|
||||
# the `applications` option consists of configuration for the above applications
|
||||
module = mkOption {
|
||||
application-configuration = mkOption {
|
||||
description = ''
|
||||
Configuration to be deployed
|
||||
'';
|
||||
type = deferredModule;
|
||||
type = submodule applications;
|
||||
};
|
||||
runtime-environment = mkOption {
|
||||
description = "The run-time environment to deploy to";
|
||||
|
@ -163,10 +148,6 @@ in
|
|||
description = "Collection of resources for use in Fediversity applications";
|
||||
type = attrsOf resource;
|
||||
};
|
||||
applications = mkOption {
|
||||
description = "Collection of (available) Fediversity applications";
|
||||
type = attrsOf application;
|
||||
};
|
||||
deployments = mkOption {
|
||||
description = "Deployment of a configuration of applications to a run-time environment";
|
||||
type = attrsOf deployment;
|
||||
|
|
Loading…
Add table
Reference in a new issue