2023-11-19 23:20:16 +01:00
|
|
|
{
|
|
|
|
inputs,
|
|
|
|
outputs,
|
|
|
|
lib,
|
|
|
|
config,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}: {
|
|
|
|
#this came from https://jacobneplokh.com/how-to-setup-nextcloud-on-nixos/
|
|
|
|
services.nginx = {
|
|
|
|
enable = true;
|
|
|
|
|
|
|
|
# Use recommended settings
|
|
|
|
recommendedGzipSettings = true;
|
|
|
|
recommendedOptimisation = true;
|
|
|
|
recommendedProxySettings = true;
|
|
|
|
recommendedTlsSettings = true;
|
|
|
|
|
|
|
|
# Only allow PFS-enabled ciphers with AES256
|
|
|
|
sslCiphers = "AES256+EECDH:AES256+EDH:!aNULL";
|
|
|
|
|
|
|
|
# Setup Nextcloud virtual host to listen on ports
|
|
|
|
virtualHosts = {
|
|
|
|
"nextcloud.gladtherescake.eu" = {
|
|
|
|
## Force HTTP redirect to HTTPS
|
|
|
|
forceSSL = true;
|
|
|
|
## LetsEncrypt
|
|
|
|
enableACME = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
services.nextcloud = {
|
|
|
|
enable = true;
|
|
|
|
hostName = "nextcloud.gladtherescake.eu";
|
|
|
|
|
|
|
|
# Use HTTPS for links
|
|
|
|
https = true;
|
|
|
|
|
|
|
|
# Auto-update Nextcloud Apps
|
|
|
|
autoUpdateApps.enable = true;
|
|
|
|
# Set what time makes sense for you
|
|
|
|
autoUpdateApps.startAt = "05:00:00";
|
|
|
|
|
2023-11-20 15:36:39 +01:00
|
|
|
configureRedis = true;
|
|
|
|
|
2023-11-20 20:26:17 +01:00
|
|
|
package = pkgs.nextcloud27;
|
|
|
|
|
2023-11-21 15:16:20 +01:00
|
|
|
#Directory for the data is /var/lib/nextcloud
|
2023-11-21 14:55:19 +01:00
|
|
|
|
2023-11-19 23:20:16 +01:00
|
|
|
config = {
|
|
|
|
# Further forces Nextcloud to use HTTPS
|
|
|
|
overwriteProtocol = "https";
|
|
|
|
|
|
|
|
# Nextcloud PostegreSQL database configuration, recommended over using SQLite
|
2023-11-20 20:26:17 +01:00
|
|
|
dbtype = "mysql";
|
2023-11-19 23:20:16 +01:00
|
|
|
dbuser = "nextcloud";
|
2023-11-20 20:26:17 +01:00
|
|
|
dbhost = "/run/mysql";
|
|
|
|
dbname = "NC";
|
2023-11-22 18:27:35 +01:00
|
|
|
dbport = 3306;
|
2023-11-20 16:30:00 +01:00
|
|
|
dbpassFile = config.sops.secrets."nextclouddb".path;
|
2023-11-19 23:20:16 +01:00
|
|
|
|
|
|
|
#TODO: work with sops to set this instead of a file & make sure the db setup is the same as on the previous server for easy migration
|
2023-11-20 16:19:52 +01:00
|
|
|
adminpassFile = config.sops.secrets."nextcloudadmin".path;
|
2023-11-21 19:42:05 +01:00
|
|
|
adminuser = "gladtherescake";
|
2023-11-19 23:20:16 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2023-11-20 20:26:17 +01:00
|
|
|
services.mysql = {
|
2023-11-22 18:27:35 +01:00
|
|
|
settings = {
|
2023-11-22 18:46:08 +01:00
|
|
|
server = {
|
|
|
|
skip_name_resolve = 1;
|
|
|
|
innodb_buffer_pool_size = "128M";
|
|
|
|
innodb_buffer_pool_instances = 1;
|
|
|
|
innodb_flush_log_at_trx_commit = 2;
|
|
|
|
innodb_log_buffer_size = "32M";
|
|
|
|
innodb_max_dirty_pages_pct = 90;
|
|
|
|
query_cache_type = 1;
|
|
|
|
query_cache_limit = "2M";
|
|
|
|
query_cache_min_res_unit = "2k";
|
|
|
|
query_cache_size = "64M";
|
|
|
|
tmp_table_size = "64M";
|
|
|
|
max_heap_table_size = "64M";
|
|
|
|
slow_query_log = 1;
|
|
|
|
long_query_time = 1;
|
|
|
|
};
|
2023-11-22 18:27:35 +01:00
|
|
|
mysqld = {
|
|
|
|
port = 3306;
|
2023-11-22 18:47:35 +01:00
|
|
|
character_set_server = "utf8mb4";
|
|
|
|
collation_server = "utf8mb4_general_ci";
|
|
|
|
transaction_isolation = "READ-COMMITTED";
|
|
|
|
binlog_format = "ROW";
|
|
|
|
innodb_large_prefix = "on";
|
|
|
|
innodb_file_format = "barracuda";
|
2023-11-22 18:46:08 +01:00
|
|
|
innodb_file_per_table = 1;
|
2023-11-22 18:27:35 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2023-11-19 23:20:16 +01:00
|
|
|
enable = true;
|
|
|
|
|
2023-11-20 20:26:17 +01:00
|
|
|
package = pkgs.mariadb_110;
|
2023-11-21 14:55:19 +01:00
|
|
|
|
2023-11-21 15:16:20 +01:00
|
|
|
#Directory for the database is /var/lib/mysql
|
2023-11-21 14:55:19 +01:00
|
|
|
|
2023-11-19 23:20:16 +01:00
|
|
|
# Ensure the database, user, and permissions always exist
|
2023-11-22 17:44:07 +01:00
|
|
|
ensureDatabases = ["NC"];
|
|
|
|
ensureUsers = [
|
|
|
|
{
|
|
|
|
name = "nextcloud";
|
|
|
|
ensurePermissions = {
|
|
|
|
"NC.*" = "ALL PRIVILEGES";
|
|
|
|
};
|
|
|
|
}
|
|
|
|
];
|
2023-11-19 23:20:16 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
systemd.services."nextcloud-setup" = {
|
2023-11-20 20:26:17 +01:00
|
|
|
requires = ["mysql.service"];
|
|
|
|
after = ["mysql.service"];
|
2023-11-19 23:20:16 +01:00
|
|
|
};
|
|
|
|
}
|