2017-01-08 11:42:39 +00:00
|
|
|
{ lib, pkgs, config, ... }:
|
|
|
|
with lib;
|
|
|
|
|
2021-01-03 09:59:50 +00:00
|
|
|
# services.redis.enable = true;
|
|
|
|
# to enable caching with redis first start up everything, then run:
|
|
|
|
# nextcloud-occ config:system:set redis 'host' --value 'localhost' --type string
|
|
|
|
# nextcloud-occ config:system:set redis 'port' --value 6379 --type integer
|
|
|
|
# nextcloud-occ config:system:set memcache.local --value '\OC\Memcache\Redis' --type string
|
|
|
|
# nextcloud-occ config:system:set memcache.locking --value '\OC\Memcache\Redis' --type string
|
|
|
|
|
|
|
|
# services.memcached.enable = true;
|
|
|
|
# to enable caching with memcached run:
|
|
|
|
# nextcloud-occ config:system:set memcached_servers 0 0 --value 127.0.0.1 --type string
|
|
|
|
# nextcloud-occ config:system:set memcached_servers 0 1 --value 11211 --type integer
|
|
|
|
# nextcloud-occ config:system:set memcache.local --value '\OC\Memcache\APCu' --type string
|
|
|
|
# nextcloud-occ config:system:set memcache.distributed --value '\OC\Memcache\Memcached' --type string
|
|
|
|
|
2017-01-08 11:42:39 +00:00
|
|
|
let
|
2021-01-03 01:03:12 +00:00
|
|
|
adminpw = "/run/secret/nextcloud-admin-pw";
|
|
|
|
dbpw = "/run/secret/nextcloud-db-pw";
|
|
|
|
in {
|
2021-01-03 09:59:50 +00:00
|
|
|
|
2022-06-06 19:20:28 +00:00
|
|
|
fileSystems."/var/lib/nextcloud/data" = {
|
|
|
|
device = "/media/cloud/nextcloud-data";
|
|
|
|
options = [ "bind" ];
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2021-01-03 01:03:12 +00:00
|
|
|
krebs.secret.files.nextcloud-db-pw = {
|
|
|
|
path = dbpw;
|
|
|
|
owner.name = "nextcloud";
|
|
|
|
source-path = toString <secrets> + "/nextcloud-db-pw";
|
|
|
|
};
|
|
|
|
|
|
|
|
krebs.secret.files.nextcloud-admin-pw = {
|
|
|
|
path = adminpw;
|
|
|
|
owner.name = "nextcloud";
|
|
|
|
source-path = toString <secrets> + "/nextcloud-admin-pw";
|
|
|
|
};
|
|
|
|
|
|
|
|
services.nginx.virtualHosts."o.euer.krebsco.de" = {
|
|
|
|
forceSSL = true;
|
|
|
|
enableACME = true;
|
|
|
|
};
|
2021-04-04 08:23:40 +00:00
|
|
|
services.postgresqlBackup = {
|
|
|
|
enable = true;
|
|
|
|
databases = [ config.services.nextcloud.config.dbname ];
|
|
|
|
};
|
2022-06-06 19:20:28 +00:00
|
|
|
systemd.services.postgresqlBackup-nextcloud.serviceConfig.SupplementaryGroups = [ "download" ];
|
|
|
|
|
2021-04-04 08:23:40 +00:00
|
|
|
state = [
|
|
|
|
# services.postgresql.dataDir
|
|
|
|
# "${config.services.nextcloud.home}/config"
|
|
|
|
config.services.postgresqlBackup.location
|
|
|
|
];
|
|
|
|
|
2022-06-06 19:20:28 +00:00
|
|
|
users.users.nextcloud.extraGroups = [ "download" ];
|
2021-01-03 01:03:12 +00:00
|
|
|
services.nextcloud = {
|
|
|
|
enable = true;
|
2022-09-23 22:30:03 +00:00
|
|
|
package = pkgs.nextcloud24;
|
2021-01-03 01:03:12 +00:00
|
|
|
hostName = "o.euer.krebsco.de";
|
|
|
|
# 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";
|
|
|
|
|
2021-01-03 09:59:50 +00:00
|
|
|
caching.redis = true;
|
2022-06-06 19:20:28 +00:00
|
|
|
caching.apcu = true;
|
2021-01-03 01:03:12 +00:00
|
|
|
config = {
|
|
|
|
# Further forces Nextcloud to use HTTPS
|
|
|
|
overwriteProtocol = "https";
|
2022-06-06 19:20:28 +00:00
|
|
|
defaultPhoneRegion = "DE";
|
2021-01-03 01:03:12 +00: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";
|
|
|
|
dbpassFile = dbpw;
|
|
|
|
adminpassFile = adminpw;
|
2022-06-06 19:20:28 +00:00
|
|
|
adminuser = "root";
|
2017-01-08 11:42:39 +00:00
|
|
|
};
|
2021-01-03 01:03:12 +00:00
|
|
|
};
|
2021-01-03 09:59:50 +00:00
|
|
|
services.redis.enable = true;
|
2021-06-05 13:52:06 +00:00
|
|
|
systemd.services.redis.serviceConfig.LimitNOFILE=mkForce "65536";
|
2021-01-03 01:03:12 +00:00
|
|
|
services.postgresql = {
|
|
|
|
enable = true;
|
|
|
|
# Ensure the database, user, and permissions always exist
|
|
|
|
ensureDatabases = [ "nextcloud" ];
|
|
|
|
ensureUsers = [ { name = "nextcloud"; ensurePermissions."DATABASE nextcloud" = "ALL PRIVILEGES"; } ];
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.services."nextcloud-setup" = {
|
|
|
|
requires = ["postgresql.service"];
|
|
|
|
after = ["postgresql.service"];
|
|
|
|
};
|
2017-01-08 11:42:39 +00:00
|
|
|
}
|