nextcloud docker working

This commit is contained in:
Elias Gasparis 2025-06-01 22:39:20 +08:00
parent bc78646407
commit 07ec8df992
8 changed files with 231 additions and 37 deletions

View file

@ -0,0 +1,56 @@
#
# Nextcloud Service Configuration
#
services.nextcloud = {
enable = true;
# The hostname Nextcloud will use. This should be how you access it in your browser.
# If you don't have a domain, use your server's IP address.
hostName = "nextcloud.local"; # <--- IMPORTANT: Change to your actual domain or IP
# Use the built-in web server (Apache in this case) provided by the Nextcloud module.
# This means you don't need to configure services.httpd or services.nginx separately.
inheritBuiltinWebserver = true;
# Directory where Nextcloud will store user data.
# Ensure this path is on a persistent storage volume.
dataDir = "/var/lib/nextcloud/data"; # <--- IMPORTANT: Ensure this path is suitable for your setup
# Database configuration: PostgreSQL is recommended for production.
database = {
type = "postgresql";
createLocally = true; # NixOS will manage and create the PostgreSQL database
userName = "nextcloud"; # Database username for Nextcloud
# Securely store the database password in a file.
# You MUST create this file before rebuilding your system (see instructions below).
passwordFile = "/run/keys/nextcloud-db-password";
};
# Nextcloud application-specific configuration options.
# These map directly to Nextcloud's config.php settings.
config = {
# The host Nextcloud will use for internal redirects. Should match hostName.
overwritehost = "nextcloud.local"; # <--- IMPORTANT: Adjust if using a different hostname/IP
# List of trusted domains/IPs from which Nextcloud can be accessed.
# Add your server's IP address and any domain names you'll use.
trusted_domains = [
"nextcloud.local" # <--- IMPORTANT: Add your domain or IP here
"192.168.1.100" # <--- IMPORTANT: Replace with your server's actual IP address
];
# Configure local memory caching for performance. APCu is recommended.
memcache.local = "\\OC\\Memcache\\APCu";
};
# PHP FPM options required by Nextcloud for optimal performance.
phpOptions = {
"opcache.enable" = true;
"opcache.interned_strings_buffer" = 8;
"opcache.max_accelerated_files" = 10000;
"opcache.memory_consumption" = 128;
"opcache.save_comments" = 1;
"opcache.revalidate_freq" = 1;
"apc.enable_cli" = 1;
};
};

View file

@ -0,0 +1,47 @@
# nextcloud.nix
# from Linux Unplugged
{ config, pkgs, ... }:
{
services.nextcloud = {
enable = true;
hostName = "nextcloud.knossos.arkadi.one";
# Need to manually increment with every major upgrade.
package = pkgs.nextcloud30;
# Let NixOS install and configure the database automatically.
database.createLocally = true;
# Let NixOS install and configure Redis caching automatically.
configureRedis = true;
# Increase the maximum file upload size.
maxUploadSize = "16G";
https = true;
autoUpdateApps.enable = true;
extraAppsEnable = true;
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 calendar contacts notes onlyoffice tasks cookbook;
};
settings = {
#overwriteprotocol = "https";
trusted_proxies = [ "localhost" "127.0.0.1" "100.82.24.89" ];
#trusted_domains = [ "nextcloud.knossos.arkadi.one" ];
};
config = {
dbtype = "pgsql";
adminuser = "admin";
adminpassFile = "/var/lib/secrets/nextcloud-admin-pass";
};
# Suggested by Nextcloud's health check.
phpOptions."opcache.interned_strings_buffer" = "16";
};
/*
# Nightly database backups.
postgresqlBackup = {
enable = true;
startAt = "*-*-* 01:15:00";
};
*/
services.nginx.virtualHosts."nextcloud.knossos.arkadi.one".listen = [ { addr = "127.0.0.1"; port = 8009; } ];
}

View file

@ -5,5 +5,5 @@ sudo systemctl stop nextcloud-cron
sudo systemctl stop phpfm-nextcloud
sudo systemctl stop redis-nextcloud
sudo rm -rf /var/lib/nextcloud
sudo rm -rf /var/lib/postgresql
#sudo rm -rf /var/lib/postgresql
#sudo rm -rf /var/lib/redis-nextcloud

View file

@ -1,41 +1,14 @@
{ config, pkgs, ... }:
{
services.nextcloud = {
enable = true;
configureRedis = true;
package = pkgs.nextcloud30;
hostName = "nextcloud.knossos";
datadir = "/home/elias/nextcloud/";
settings = {
overwriteprotocol = "https";
trusted_proxies = [ "localhost" "127.0.0.1" "100.82.24.89" ];
#trusted_domains = [ "knossos.zebra-rudd.ts.net" ];
};
config = {
dbtype = "pgsql";
dbuser = "nextcloud";
dbhost = "/run/postgresql"; # nextcloud will add /.s.PGSQL.5432 by itself
dbname = "nextcloud";
adminpassFile = "/var/lib/secrets/nextcloud-admin-pass";
adminuser = "admin";
};
enable = true;
package = pkgs.nextcloud31;
hostName = "nextcloud.knossos";
config.adminpassFile = "/var/lib/nextcloud-admin-pass";
config.dbtype = "sqlite";
};
services.postgresql = {
enable = true;
ensureDatabases = [ "nextcloud" ];
ensureUsers = [
{ name = "nextcloud";
ensureDBOwnership = true;
}
];
};
# ensure that postgres is running *before* running the setup
systemd.services."nextcloud-setup" = {
requires = ["postgresql.service"];
after = ["postgresql.service"];
};
services.nginx.virtualHosts."nextcloud.knossos".listen = [ { addr = "127.0.0.1"; port = 8009; } ];

View file

@ -0,0 +1,42 @@
{ config, pkgs, ... }:
{
services.nextcloud = {
enable = true;
configureRedis = true;
package = pkgs.nextcloud31;
hostName = "nextcloud.knossos";
datadir = "/var/lib/nextcloud/";
settings = {
overwriteprotocol = "https";
trusted_proxies = [ "localhost" "127.0.0.1" "100.82.24.89" ];
trusted_domains = [ "nextcloud.knossos.arkadi.one" ];
};
config = {
dbtype = "pgsql";
dbuser = "nextcloud";
dbhost = "/run/postgresql"; # nextcloud will add /.s.PGSQL.5432 by itself
dbname = "nextcloud";
adminpassFile = "/var/lib/secrets/nextcloud-admin-pass";
adminuser = "admin";
};
};
services.postgresql = {
enable = true;
ensureDatabases = [ "nextcloud" ];
ensureUsers = [
{ name = "nextcloud";
ensureDBOwnership = true;
}
];
};
# ensure that postgres is running *before* running the setup
systemd.services."nextcloud-setup" = {
requires = ["postgresql.service"];
after = ["postgresql.service"];
};
services.nginx.virtualHosts."nextcloud.knossos".listen = [ { addr = "127.0.0.1"; port = 8009; } ];
}