haccfiles/services/nextcloud.nix

102 lines
3 KiB
Nix
Raw Normal View History

{ config, lib, pkgs, evalConfig, ... }:
2021-08-06 17:40:57 +00:00
{
containers.nextcloud = {
autoStart = true;
privateNetwork = true;
hostAddress = "192.168.100.1";
localAddress = "192.168.100.2";
bindMounts = {
"/persist" = {
hostPath = "/persist/containers/nextcloud";
isReadOnly = false;
};
};
path = evalConfig ({ config, lib, pkgs, profiles, sources, ... }: {
2021-08-06 17:40:57 +00:00
imports = [
2022-11-09 23:51:51 +00:00
(import "${sources.nixpkgs-unstable}/nixos/modules/services/web-apps/nextcloud.nix")
2021-08-06 17:40:57 +00:00
];
2022-11-09 23:51:51 +00:00
disabledModules = [
"services/web-apps/nextcloud.nix"
];
2021-08-06 17:40:57 +00:00
environment.systemPackages = [ pkgs.htop ];
2022-11-09 23:40:25 +00:00
services.nextcloud = {
2021-08-06 17:40:57 +00:00
enable = true;
# must be set manually; may not be incremented by more than one at
# a time, otherwise nextcloud WILL break
2023-09-27 16:24:18 +00:00
package = pkgs.nextcloud27;
2021-08-06 17:40:57 +00:00
home = "/persist/nextcloud";
https = true;
# true by default for backwards-compatability, but we don't need it
enableBrokenCiphersForSSE = false;
2021-08-06 17:40:57 +00:00
hostName = "cloud.infra4future.de";
config = {
dbtype = "pgsql";
dbuser = "nextcloud";
dbhost = "/run/postgresql"; # nextcloud will add /.s.PGSQL.5432 by itself
dbname = "nextcloud";
# socket auth does not needs this, but the module insists it does
2023-09-27 16:24:18 +00:00
adminpassFile = "/persist/adminpassfile";
2021-08-06 17:40:57 +00:00
adminuser = "root";
};
# multiple pools may be doable using services.phpfpm.pools,
# but i have not tried this yet. The nextcloud module defines a
# pool "nextcloud"
poolSettings = {
pm = "dynamic";
"pm.max_children" = "32";
"pm.max_requests" = "500";
"pm.max_spare_servers" = "4";
"pm.min_spare_servers" = "2";
"pm.start_servers" = "2";
};
extraOptions = {
instanceid = "ocxlphb7fbju";
datadirectory = "/persist/nextcloud/data";
2021-08-06 17:40:57 +00:00
loglevel = 0;
"overwrite.cli.url" = "https://cloud.infra4future.de";
};
};
services.postgresql = {
enable = true;
2022-01-27 20:20:25 +00:00
package = pkgs.postgresql_11;
2021-08-06 17:40:57 +00:00
ensureDatabases = [ "nextcloud" ];
ensureUsers = [
{ # by default, postgres has unix sockets enabled, and allows a
# system user `nextcloud` to log in without other authentication
name = "nextcloud";
ensurePermissions."DATABASE nextcloud" = "ALL PRIVILEGES";
}
];
};
# ensure that postgres is running *before* running the setup
systemd.services."nextcloud-setup" = {
requires = ["postgresql.service"];
after = ["postgresql.service"];
};
});
2021-08-06 17:40:57 +00:00
};
services.nginx.virtualHosts."cloud.infra4future.de" = {
locations."/".proxyPass = "http://${config.containers.nextcloud.localAddress}:80";
enableACME = true;
forceSSL = true;
extraConfig = ''
proxy_buffering off;
client_max_body_size 0;
add_header Cache-Control "no-store, no-cache, must-revalidate";
'';
2021-08-06 17:40:57 +00:00
};
}