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

37 lines
1.3 KiB
Nix
Raw Normal View History

2023-11-15 21:37:20 +08:00
inputs:
{
options.nixos.services.nginx.applications.webdav.instances = let inherit (inputs.lib) mkOption types; in mkOption
2023-11-15 21:37:20 +08:00
{
type = types.attrsOf (types.submodule (submoduleInputs: { options =
{
hostname = mkOption { type = types.nonEmptyStr; default = submoduleInputs.config._module.args.name; };
path = mkOption { type = types.nonEmptyStr; default = "/srv/webdav"; };
users = mkOption { type = types.nonEmptyListOf types.nonEmptyStr; default = [ "chn" ]; };
};}));
default = {};
2023-11-15 21:37:20 +08:00
};
config =
let
inherit (inputs.config.nixos.services.nginx.applications.webdav) instances;
2023-11-19 02:35:06 +08:00
inherit (builtins) map listToAttrs attrValues;
inherit (inputs.lib) mkMerge;
in
2023-11-15 21:37:20 +08:00
{
nixos.services.nginx.https = listToAttrs (map
(site:
{
name = site.hostname;
value.location."/".static =
{ root = site.path; index = "auto"; charset = "utf-8"; webdav = true; detectAuth.users = site.users; };
})
2023-11-19 02:35:06 +08:00
(attrValues instances));
systemd = mkMerge (map
(site:
{
2023-12-15 20:20:30 +08:00
tmpfiles.rules = [ "d ${site.path} 0700 nginx nginx" "Z ${site.path} - nginx nginx" ];
services.nginx.serviceConfig.ReadWritePaths = [ site.path ];
})
2023-11-19 02:35:06 +08:00
(attrValues instances));
2023-11-15 21:37:20 +08:00
};
}