NixOS-Config/nixos/queen/nextcloud.nix

131 lines
3.5 KiB
Nix
Raw Normal View History

2023-11-19 23:20:16 +01:00
{
config,
pkgs,
...
}: {
2023-11-23 14:55:06 +01:00
# Enable Nginx
services.nginx = {
enable = true;
2023-11-19 23:20:16 +01:00
2023-11-23 14:55:06 +01:00
# Use recommended settings
recommendedGzipSettings = true;
recommendedOptimisation = true;
recommendedProxySettings = true;
recommendedTlsSettings = true;
2023-11-19 23:20:16 +01:00
2023-11-23 14:55:06 +01:00
# Only allow PFS-enabled ciphers with AES256
sslCiphers = "AES256+EECDH:AES256+EDH:!aNULL";
2023-11-19 23:20:16 +01:00
2023-11-23 14:55:06 +01:00
# Setup Nextcloud virtual host to listen on ports
virtualHosts = {
"nextcloud.gladtherescake.eu" = {
## Force HTTP redirect to HTTPS
forceSSL = true;
## LetsEncrypt
enableACME = true;
};
"onlyoffice.gladtherescake.eu" = {
2023-11-23 19:24:27 +01:00
forceSSL = true;
enableACME = true;
};
2023-11-23 14:55:06 +01:00
};
2023-11-19 23:20:16 +01:00
};
2023-11-23 14:55:06 +01:00
# Actual Nextcloud Config
2023-11-19 23:20:16 +01:00
services.nextcloud = {
enable = true;
hostName = "nextcloud.gladtherescake.eu";
2023-11-23 14:35:01 +01:00
2023-11-23 15:23:59 +01:00
package = pkgs.nextcloud27;
2023-11-23 14:55:06 +01:00
# Use HTTPS for links
https = true;
2023-11-19 23:20:16 +01:00
2023-11-23 14:55:06 +01:00
# Auto-update Nextcloud Apps
autoUpdateApps.enable = true;
# Set what time makes sense for you
autoUpdateApps.startAt = "05:00:00";
2023-11-23 19:24:27 +01:00
configureRedis = true;
maxUploadSize = "16G";
2023-11-19 23:20:16 +01:00
2023-11-24 17:46:22 +01:00
#Increase opcache string buffer
phpOptions."opcache.interned_strings_buffer" = "23";
2023-11-23 19:57:25 +01:00
extraAppsEnable = true;
extraApps = with config.services.nextcloud.package.packages.apps; {
# List of apps we want to install and are already packaged in
# https://github.com/NixOS/nixpkgs/blob/master/pkgs/servers/nextcloud/packages/nextcloud-apps.json
inherit calendar contacts deck forms music news notes onlyoffice polls twofactor_nextcloud_notification unsplash;
};
2023-11-23 14:55:06 +01:00
config = {
# Further forces Nextcloud to use HTTPS
overwriteProtocol = "https";
2023-11-22 18:27:35 +01:00
2023-11-23 19:24:27 +01:00
defaultPhoneRegion = "NL";
2023-11-23 14:55:06 +01:00
# Nextcloud PostegreSQL database configuration, recommended over using SQLite
dbtype = "pgsql";
dbuser = "nextcloud";
dbhost = "/run/postgresql"; # nextcloud will add /.s.PGSQL.5432 by itself
dbname = "nextcloud";
2023-11-23 15:03:46 +01:00
dbpassFile = config.sops.secrets."nextclouddb".path;
2023-11-19 23:20:16 +01:00
2023-11-23 15:03:46 +01:00
adminpassFile = config.sops.secrets."nextcloudadmin".path;
2023-11-23 15:10:34 +01:00
adminuser = "GLaDTheresCake";
2023-11-23 14:35:01 +01:00
};
};
2023-11-21 14:55:19 +01:00
2023-11-23 19:28:07 +01:00
services.onlyoffice = {
2023-11-23 19:24:27 +01:00
enable = true;
hostname = "onlyoffice.gladtherescake.eu";
2023-11-24 22:29:44 +01:00
#postgresHost = "/run/postgesql";
#postgresUser = "onlyoffice";
#postgresName = "onlyoffice";
#jwtSecretFile = config.sops.secrets."local.json".path;
2023-11-23 19:24:27 +01:00
};
services.rabbitmq = {
enable = true;
};
2023-11-23 14:55:06 +01:00
# Enable PostgreSQL
services.postgresql = {
enable = true;
2023-11-19 23:20:16 +01:00
2023-11-26 19:16:15 +01:00
package = pkgs.postgresql_15;
2023-11-26 19:10:42 +01:00
2023-11-23 14:55:06 +01:00
# Ensure the database, user, and permissions always exist
2023-11-25 14:49:56 +01:00
ensureDatabases = ["nextcloud" "onlyoffice" "akkoma"];
2023-11-23 14:55:06 +01:00
ensureUsers = [
{
name = "nextcloud";
ensurePermissions."DATABASE nextcloud" = "ALL PRIVILEGES";
2023-11-23 14:55:06 +01:00
}
2023-11-23 20:16:43 +01:00
{
name = "onlyoffice";
ensurePermissions."DATABASE onlyoffice" = "ALL PRIVILEGES";
}
2023-11-25 14:49:56 +01:00
{
name = "akkoma";
ensurePermissions."DATABASE akkoma" = "ALL PRIVILEGES";
}
2023-11-23 14:55:06 +01:00
];
};
2023-11-23 13:11:03 +01:00
2023-11-23 17:13:26 +01:00
services.aria2 = {
enable = true;
2023-11-23 17:23:27 +01:00
rpcListenPort = 6969;
2023-11-23 17:13:26 +01:00
};
2023-11-23 15:14:44 +01:00
systemd.services."sops-nix.service" = {
2023-11-24 22:33:06 +01:00
before = ["nextcloud-setup.service" "postgresql.service" "onlyoffice-converter.service" "onlyoffice-docservice.service" "nginx.service" "phpfpm-nextcloud.service" "redis-nextcloud.service"];
2023-11-23 15:14:44 +01:00
};
2023-11-23 14:55:06 +01:00
# Ensure that postgres is running before running the setup
systemd.services."nextcloud-setup" = {
requires = ["postgresql.service"];
after = ["postgresql.service"];
2023-11-19 23:20:16 +01:00
};
}