mirror of
https://github.com/Swarsel/.dotfiles.git
synced 2026-04-14 21:29:12 +02:00
72 lines
2.9 KiB
Nix
72 lines
2.9 KiB
Nix
{ pkgs, lib, config, globals, dns, confLib, ... }:
|
|
let
|
|
inherit (config.repo.secrets.local.nextcloud) adminuser;
|
|
inherit (config.swarselsystems) sopsFile;
|
|
inherit (confLib.gen { name = "nextcloud"; port = 80; }) servicePort serviceName serviceUser serviceGroup serviceDomain serviceAddress proxyAddress4 proxyAddress6;
|
|
inherit (confLib.static) isHome dnsServer webProxy homeWebProxy homeServiceAddress nginxAccessRules;
|
|
|
|
nextcloudVersion = "32";
|
|
in
|
|
{
|
|
options.swarselmodules.server.${serviceName} = lib.mkEnableOption "enable ${serviceName} on server";
|
|
config = lib.mkIf config.swarselmodules.server.${serviceName} {
|
|
|
|
sops.secrets = {
|
|
nextcloud-admin-pw = { inherit sopsFile; owner = serviceUser; group = serviceGroup; mode = "0440"; };
|
|
kanidm-nextcloud-client = { inherit sopsFile; owner = serviceUser; group = serviceGroup; mode = "0440"; };
|
|
};
|
|
|
|
users.persistentIds = {
|
|
nextcloud = confLib.mkIds 990;
|
|
redis-nextcloud = confLib.mkIds 976;
|
|
};
|
|
|
|
globals.services.${serviceName} = {
|
|
domain = serviceDomain;
|
|
inherit proxyAddress4 proxyAddress6 isHome serviceAddress;
|
|
homeServiceAddress = lib.mkIf isHome homeServiceAddress;
|
|
};
|
|
|
|
environment.persistence."/state" = lib.mkIf config.swarselsystems.isMicroVM {
|
|
directories = [
|
|
{ directory = "/var/lib/${serviceName}"; user = serviceUser; group = serviceGroup; }
|
|
{ directory = "/var/lib/redis-${serviceName}"; user = serviceUser; group = serviceGroup; }
|
|
];
|
|
};
|
|
|
|
services = {
|
|
${serviceName} = {
|
|
enable = true;
|
|
settings = {
|
|
trusted_proxies = [ "0.0.0.0" ];
|
|
overwriteprotocol = "https";
|
|
};
|
|
package = pkgs."nextcloud${nextcloudVersion}";
|
|
hostName = serviceDomain;
|
|
home = "/var/lib/${serviceName}";
|
|
datadir = "/var/lib/${serviceName}";
|
|
https = true;
|
|
configureRedis = true;
|
|
maxUploadSize = "4G";
|
|
extraApps = {
|
|
inherit (pkgs."nextcloud${nextcloudVersion}Packages".apps) mail calendar contacts cospend phonetrack polls tasks sociallogin;
|
|
};
|
|
extraAppsEnable = true;
|
|
config = {
|
|
inherit adminuser;
|
|
adminpassFile = config.sops.secrets.nextcloud-admin-pw.path;
|
|
dbtype = "sqlite";
|
|
};
|
|
};
|
|
};
|
|
|
|
nodes = {
|
|
${dnsServer}.swarselsystems.server.dns.${globals.services.${serviceName}.baseDomain}.subdomainRecords = {
|
|
"${globals.services.${serviceName}.subDomain}" = dns.lib.combinators.host proxyAddress4 proxyAddress6;
|
|
};
|
|
${webProxy}.services.nginx = confLib.genNginx { inherit serviceAddress servicePort serviceDomain serviceName; maxBody = 0; };
|
|
${homeWebProxy}.services.nginx = lib.mkIf isHome (confLib.genNginx { inherit servicePort serviceDomain serviceName; maxBody = 0; extraConfig = nginxAccessRules; serviceAddress = homeServiceAddress; });
|
|
};
|
|
|
|
};
|
|
}
|