mio-ops/profiles/nextcloud.nix

82 lines
3 KiB
Nix
Raw Normal View History

2019-12-17 01:01:02 +00:00
# NixOps configuration for the hosts running Nextcloud
{ config, pkgs, lib, ... }:
{
imports =
[
../secrets/nextcloud.nix
];
services.nextcloud = {
enable = true; # Enable Nextcloud
hostName = "cloud.mcwhirter.io"; # FQDN for the Nextcloud instance
2020-08-10 11:34:39 +00:00
https = true; # Use HTTPS for links
2019-12-17 01:01:02 +00:00
config = { # Configure Nextcloud
2019-12-17 01:04:29 +00:00
dbtype = "pgsql"; # Set the database type
dbname = "nextcloud"; # Set the database name
dbhost = "/run/postgresql"; # Set the database connection
dbuser = "nextcloud"; # Set the database user
dbpassFile = "/run/keys/nextcloud-dbpass"; # Where to find the database password
adminpassFile = "/run/keys/nextcloud-admin"; # Where to find the admin password
adminuser = "root"; # Set the admin user name
2019-12-17 01:01:02 +00:00
overwriteProtocol = "https"; # Force Nextcloud to always use HTTPS
};
2020-05-04 09:05:37 +00:00
autoUpdateApps = {
enable = true; # Run regular auto update of all apps installed
startAt = "01:00:00"; # When to run the update
};
2020-12-31 01:55:41 +00:00
package = pkgs.nextcloud20;
2019-12-17 01:01:02 +00:00
};
services.postgresql = {
enable = true; # Ensure postgresql is enabled
2020-04-27 08:07:20 +00:00
ensureDatabases = [ "nextcloud" ]; # Ensure the database persists
2019-12-17 01:01:02 +00:00
ensureUsers = [
2020-04-27 08:07:20 +00:00
{
name = "nextcloud"; # Ensure the database user persists
ensurePermissions = { # Ensure the database permissions persist
"DATABASE nextcloud" = "ALL PRIVILEGES";
2020-05-04 09:05:37 +00:00
"ALL TABLES IN SCHEMA public" = "ALL PRIVILEGES";
2020-04-27 08:07:20 +00:00
};
2019-12-17 01:01:02 +00:00
}
];
};
services.nginx = {
2020-05-04 09:05:37 +00:00
enable = true; # Enable Nginx
2019-12-17 01:01:02 +00:00
recommendedGzipSettings = true;
recommendedOptimisation = true;
recommendedProxySettings = true;
recommendedTlsSettings = true;
virtualHosts."cloud.mcwhirter.io" = { # Nextcloud hostname
enableACME = true; # Use ACME certs
forceSSL = true; # Force SSL
};
virtualHosts."owncloud.mcwhirter.io" = { # Hostname to be redirected
globalRedirect = "cloud.mcwhirter.io"; # Redirect permanently to the host
};
};
2020-08-10 11:34:39 +00:00
systemd.services."nextcloud-setup" = { # Ensure PostgreSQL is running first
2019-12-17 01:01:02 +00:00
requires = ["postgresql.service"];
after = ["postgresql.service"];
};
2020-08-10 11:34:39 +00:00
security.acme = {
acceptTerms = true;
certs = {
"cloud.mcwhirter.io" = {
email = "craige@mcwhirter.io";
};
};
2019-12-17 01:01:02 +00:00
};
users.groups.keys.members = [ "nextcloud" ]; # Required due to NixOps issue #1204
users.groups.nextcloud.members = [ "nextcloud" ]; # Added for keys permissions
2019-12-17 01:04:29 +00:00
networking.firewall.allowedTCPPorts = [ 80 443 ]; # Open the required firewall ports
2019-12-17 01:01:02 +00:00
}