nixos-selfhost/nextcloud.nix

117 lines
3.1 KiB
Nix
Raw Normal View History

2024-03-01 22:15:55 +01:00
{ self, config, lib, pkgs, ... }:
2024-04-03 12:59:00 +02:00
let
domain = "cloud.sondell.org";
nextcloud = pkgs.nextcloud28;
2024-03-01 22:15:55 +01:00
in
{
2024-04-03 12:59:00 +02:00
environment.systemPackages = [
nextcloud
];
2024-06-23 08:05:34 +02:00
systemd.timers."nextcloud-db-backup" = {
2024-05-05 21:19:42 +02:00
wantedBy = [ "timers.target" ];
timerConfig = {
# OnBootSec = "5m";
# OnUnitActiveSec = "5m";
OnCalendar="*-*-* 2:00:00";
2024-06-23 08:05:34 +02:00
Unit = "nextcloud-db-backup.service";
2024-05-05 21:19:42 +02:00
};
};
2024-06-23 08:05:34 +02:00
systemd.services."nextcloud-db-backup" = {
2024-05-05 21:54:47 +02:00
script = with pkgs; ''
2024-05-05 21:19:42 +02:00
set -eu
2024-05-05 22:03:04 +02:00
${postgresql}/bin/pg_dump "nextcloud" | ${openssh}/bin/ssh -i /etc/nixos/.secrets/tulpan Glenn@nas "cat - > back/nextcloud/latest.sql"
2024-05-05 21:19:42 +02:00
'';
serviceConfig = {
Type = "oneshot";
User = "postgres";
};
};
2024-06-23 08:05:34 +02:00
2024-05-05 21:19:42 +02:00
2024-03-01 22:15:55 +01:00
services = {
2024-06-23 15:39:08 +02:00
restic.backups = {
"diskstation423" = {
passwordFile = "/etc/nixos/.secrets/restic_pw";
repository = "sftp:Glenn@nas:/home/back/nextcloud/restic-repo";
paths = [
"/pool/var/lib/nextcloud"
];
2024-06-24 08:12:35 +02:00
user = "sondell";
2024-06-23 15:39:08 +02:00
timerConfig.onCalendar = "02:05";
};
};
2024-06-23 08:05:34 +02:00
2024-03-01 22:15:55 +01:00
nginx.virtualHosts = {
${domain} = {
2024-04-02 19:25:00 +02:00
forceSSL = true;
enableACME = true;
2024-03-01 22:15:55 +01:00
# Use DNS Challenege.
# acmeRoot = null;
};
};
2024-03-02 17:32:59 +01:00
postgresql.enable = true;
2024-03-01 22:15:55 +01:00
#
nextcloud = {
enable = true;
hostName = domain;
# Need to manually increment with every major upgrade.
2024-04-03 12:59:00 +02:00
package = nextcloud;
2024-03-01 22:15:55 +01:00
# Let NixOS install and configure the database automatically.
database.createLocally = true;
# Increase the maximum file upload size.
2024-06-23 08:05:34 +02:00
datadir="/pool/var/lib/nextcloud";
2024-03-01 22:15:55 +01:00
maxUploadSize = "16G";
https = true;
autoUpdateApps.enable = true;
extraAppsEnable = true;
2024-04-03 12:59:00 +02:00
# Let NixOS install and configure Redis caching automatically.
configureRedis = true;
settings = {
maintenance_window_start = 1;
};
2024-03-27 15:30:23 +01:00
extraOptions = {
2024-04-03 12:59:00 +02:00
# redis = {
# # host = "/run/redis/redis.sock";
# port = 0;
# dbindex = 0;
# password = "secret";
# timeout = 1.5;
# };
2024-03-27 15:30:23 +01:00
};
2024-03-01 22:15:55 +01:00
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 mail calendar contacts notes onlyoffice tasks cookbook;
};
config = {
overwriteProtocol = "https";
2024-04-03 12:59:00 +02:00
defaultPhoneRegion = "SE";
2024-03-01 22:15:55 +01:00
dbtype = "pgsql";
adminuser = "admin";
adminpassFile = "/etc/nixos/.secrets/nextadminpw";
};
# Suggested by Nextcloud's health check.
phpOptions."opcache.interned_strings_buffer" = "16";
};
# Nightly database backups.
# postgresqlBackup = {
# enable = true;
# startAt = "*-*-* 01:15:00";
# };
};
2024-04-04 13:40:20 +02:00
services.onlyoffice = {
enable = true;
port = 8123;
hostname = "office.sondell.org";
};
services.nginx.virtualHosts."office.sondell.org" = {
forceSSL = true;
enableACME = true;
# locations."/".proxyPass = "http://12:8123";
};
2024-03-01 22:15:55 +01:00
}