nixos/modules/services/nginx/applications/element.nix

42 lines
1.4 KiB
Nix
Raw Normal View History

2023-10-03 21:47:46 +08:00
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 = "element.chn.moe"; };
};}));
default = {};
};
config =
let
inherit (inputs.config.nixos.services.nginx.applications.element) instances;
inherit (inputs.localLib) attrsToList;
inherit (builtins) map listToAttrs toString;
in
{
2023-11-09 12:02:05 +08:00
nixos.services.nginx.https = listToAttrs (map
2023-10-03 21:47:46 +08:00
(instance: with instance.value;
{
name = hostname;
2023-11-15 20:42:42 +08:00
value.location."/".static =
{
root =
if defaultServer == null then toString inputs.pkgs.element-web
else toString (inputs.pkgs.element-web.override { conf =
2023-10-03 21:47:46 +08:00
{
2023-11-15 20:42:42 +08:00
default_server_config."m.homeserver" =
{
base_url = "https://${defaultServer}";
server_name = defaultServer;
};
disable_guests = false;
};});
index = [ "index.html" ];
};
2023-10-03 21:47:46 +08:00
})
(attrsToList instances));
};
}