NixOS-Config/nixos/queen/nextcloud.nix

90 lines
2.1 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;
};
};
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-19 23:20:16 +01:00
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 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 14:55:06 +01:00
# Enable PostgreSQL
services.postgresql = {
enable = true;
2023-11-19 23:20:16 +01:00
2023-11-23 14:55:06 +01:00
# Ensure the database, user, and permissions always exist
ensureDatabases = ["nextcloud"];
ensureUsers = [
{
name = "nextcloud";
ensurePermissions."DATABASE nextcloud" = "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" = {
before = ["nextcloud-setup.service" "postgresql.service"];
};
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
};
}