mirror of
https://github.com/CHN-beta/nixos.git
synced 2024-10-24 16:18:44 +08:00
39 lines
1.3 KiB
Nix
39 lines
1.3 KiB
Nix
inputs:
|
|
{
|
|
options.nixos.services.nginx.applications.element.instances = let inherit (inputs.lib) mkOption types; in mkOption
|
|
{
|
|
type = types.attrsOf (types.submodule (submoduleInputs: { options =
|
|
{
|
|
hostname = mkOption { type = types.nonEmptyStr; default = submoduleInputs.config._module.args.name; };
|
|
defaultServer = mkOption { type = types.nullOr types.nonEmptyStr; default = "matrix.chn.moe"; };
|
|
};}));
|
|
default = {};
|
|
};
|
|
config =
|
|
let
|
|
inherit (inputs.config.nixos.services.nginx.applications.element) instances;
|
|
inherit (inputs.localLib) attrsToList;
|
|
inherit (builtins) map listToAttrs toString;
|
|
in
|
|
{
|
|
nixos.services.nginx.https = listToAttrs (map
|
|
(instance: with instance.value;
|
|
{
|
|
name = hostname;
|
|
value.location."/".static =
|
|
{
|
|
root =
|
|
if defaultServer == null then toString inputs.pkgs.element-web
|
|
else toString (inputs.pkgs.element-web.override { conf =
|
|
{
|
|
default_server_config."m.homeserver" =
|
|
{ base_url = "https://${defaultServer}"; server_name = defaultServer; };
|
|
disable_guests = false;
|
|
};});
|
|
index = [ "index.html" ];
|
|
};
|
|
})
|
|
(attrsToList instances));
|
|
};
|
|
}
|