grimm-nixos-laptop/modules/nextcloud.nix

88 lines
2.1 KiB
Nix
Raw Normal View History

2024-05-08 21:50:08 +02:00
{
lib,
pkgs,
config,
...
}:
2024-05-08 21:49:37 +02:00
let
inherit (config.networking) domain;
nextcloud_host = "cloud.${domain}";
nextcloud_port = 8083;
2024-05-08 21:50:08 +02:00
in
{
2024-05-08 21:49:37 +02:00
services.postgresql = {
enable = true;
ensureDatabases = [ "nextcloud" ];
ensureUsers = [
{
name = "nextcloud";
ensureDBOwnership = true;
}
];
};
security.acme.certs."${domain}".extraDomainNames = [ nextcloud_host ];
age.secrets = {
nextcloud_admin_pass = {
file = ../secrets/nextcloud_admin_pass.age;
owner = "nextcloud";
group = "nextcloud";
mode = "0600";
};
};
services.redis.servers.nextcloud = {
enable = true;
bind = "::1";
port = 6379;
};
systemd.services.nextcloud-setup.serviceConfig.ExecStartPost = pkgs.writeScript "nextcloud-redis.sh" ''
#!${pkgs.runtimeShell}
nextcloud-occ config:system:set redis 'host' --value '::1' --type string
nextcloud-occ config:system:set redis 'port' --value 6379 --type integer
nextcloud-occ config:system:set memcache.local --value '\OC\Memcache\Redis' --type string
nextcloud-occ config:system:set memcache.locking --value '\OC\Memcache\Redis' --type string
2024-05-08 21:50:08 +02:00
'';
2024-05-08 21:49:37 +02:00
services.nextcloud = {
enable = true;
https = true;
hostName = nextcloud_host;
package = pkgs.nextcloud28;
caching.redis = true;
2024-05-08 21:50:08 +02:00
# extraApps = with config.services.nextcloud.package.packages.apps; [
# news contacts calendar tasks;
# ];
2024-05-08 21:49:37 +02:00
config = {
adminpassFile = config.age.secrets.nextcloud_admin_pass.path;
dbuser = "nextcloud";
2024-05-08 21:50:08 +02:00
dbhost = "localhost:${builtins.toString config.services.postgresql.settings.port}";
2024-05-08 21:49:37 +02:00
dbtype = "pgsql";
};
settings = {
overwriteProtocol = "https";
defaultPhoneRegion = "DE";
filelocking.enabled = true;
redis = {
host = "localhost";
port = 6379;
timeout = 0.0;
};
};
phpOptions = {
"opcache.interned_strings_buffer" = "12";
};
};
services.nginx = {
enable = true;
virtualHosts."${nextcloud_host}" = {
serverName = nextcloud_host;
forceSSL = true;
useACMEHost = domain;
};
};
}