nixos/hosts/hub/apps/nextcloud.nix

110 lines
3.5 KiB
Nix
Raw Normal View History

2024-12-18 18:19:37 -06:00
{
services.postgresql = {
ensureDatabases = [ "nextcloud" ];
ensureUsers = [
{
name = "nextcloud";
ensureDBOwnership = true;
}
];
};
containers.nextcloud = {
autoStart = true;
privateNetwork = true;
hostAddress = "192.168.0.1";
localAddress = "192.168.0.3";
config =
{
config,
pkgs,
lib,
...
}:
{
environment.etc."nextcloud-admin-pass".text = "admin";
nixpkgs.config.allowUnfree = true;
services = {
nextcloud = {
enable = true;
hostName = "nextcloud.thewordnerd.info";
package = pkgs.nextcloud31;
2024-12-18 18:19:37 -06:00
configureRedis = true;
maxUploadSize = "16G";
2024-12-23 11:20:27 -06:00
# autoUpdateApps.enable = true;
2025-02-14 13:01:44 -06:00
notify_push = {
enable = true;
bendDomainToLocalhost = true;
};
2024-12-18 18:19:37 -06:00
webfinger = true;
settings = {
overwriteprotocol = "https";
2025-02-14 13:01:44 -06:00
trusted_proxies = [
"192.168.0.1"
];
2024-12-18 18:19:37 -06:00
default_phone_region = "US";
2025-02-14 13:01:44 -06:00
# loglevel = 0;
2024-12-18 18:19:37 -06:00
};
config = {
dbtype = "pgsql";
dbhost = "/run/postgresql";
adminpassFile = "/etc/nextcloud-admin-pass";
};
2024-12-23 11:20:27 -06:00
phpOptions."opcache.interned_strings_buffer" = "23";
2024-12-18 18:19:37 -06:00
};
resolved.enable = true;
};
# IMPORTANT: Nextcloud container startup workaround
# The nextcloud-setup service blocks container startup when it needs to perform upgrades,
# creating a circular dependency: the network can't be configured until the container is ready,
# but the container can't be ready without network access for the upgrade.
#
# To upgrade Nextcloud when changing major versions:
# 1. Uncomment the lines below to disable nextcloud-setup
# 2. Run: nixos-rebuild switch
# 3. Run: nixos-container run nextcloud -- nextcloud-occ upgrade
# 4. Run: nixos-container run nextcloud -- nextcloud-occ maintenance:mode --off
# 5. Comment out the lines below again
# 6. Run: nixos-rebuild switch
#
# systemd.services.nextcloud-setup = {
# enable = false;
# };
2024-12-23 11:20:27 -06:00
programs.nix-ld.enable = true;
2024-12-18 18:19:37 -06:00
networking = {
firewall.allowedTCPPorts = [ 80 ];
useHostResolvConf = lib.mkForce false;
};
# virtualisation.docker.enable = true;
# users.users.nextcloud.extraGroups = [ "docker" ];
2025-05-16 12:49:12 -05:00
environment.systemPackages = with pkgs; [
poppler_utils
# (pkgs.writeScriptBin "occ" ''
# #!${pkgs.bash}/bin/bash
# exec nextcloud-occ "$@"
# '')
2025-02-14 13:01:44 -06:00
];
2025-05-16 12:49:12 -05:00
programs.java.binfmt = true;
2025-04-18 19:40:45 -05:00
system.stateVersion = "24.11";
2024-12-18 18:19:37 -06:00
};
2025-02-14 13:01:44 -06:00
# https://discourse.nixos.org/t/podman-docker-in-nixos-container-ideally-in-unprivileged-one/22909/12
# additionalCapabilities = [
# ''all" --system-call-filter="add_key keyctl bpf" --capability="all''
# ];
2024-12-18 18:19:37 -06:00
bindMounts = {
2024-12-23 11:20:27 -06:00
"/run/postgresql" = {
hostPath = "/run/postgresql";
2024-12-18 18:19:37 -06:00
};
};
};
2024-12-23 11:20:27 -06:00
services.caddy.virtualHosts."nextcloud.thewordnerd.info".extraConfig = ''
reverse_proxy nextcloud
header Strict-Transport-Security max-age=31536000;
'';
2025-02-14 13:01:44 -06:00
services.caddy.virtualHosts."collabora.thewordnerd.info".extraConfig = ''
reverse_proxy nextcloud:9980
'';
2024-12-18 18:19:37 -06:00
}