NixOS-Config/nixos/queen/nextcloud.nix

79 lines
1.9 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 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:02:52 +01:00
dbpassFile = sops.secrets."nextclouddb".path;
2023-11-19 23:20:16 +01:00
2023-11-23 15:02:52 +01:00
adminpassFile = sops.secrets."nextcloudadmin".path;
2023-11-23 14:55:06 +01:00
adminuser = "admin";
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";
2023-11-23 15:02:52 +01:00
ensureDBOwnership."DATABASE nextcloud" = "ALL PRIVILEGES";
2023-11-23 14:55:06 +01:00
}
];
};
2023-11-23 13:11:03 +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
};
}