2023-04-04 22:56:30 -07:00
|
|
|
|
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
containers.nextcloud = {
|
|
|
|
autoStart = true;
|
|
|
|
privateNetwork = true;
|
2023-04-07 16:50:38 -07:00
|
|
|
# The host address is the address of the parent machine from inside the container
|
2023-04-04 22:56:30 -07:00
|
|
|
hostAddress = "192.168.100.10";
|
2023-04-07 16:50:38 -07:00
|
|
|
# The local address field is the "inside the container" address of this machine
|
|
|
|
# Or what it says when you run 'ip a' inside the container
|
2023-04-04 22:56:30 -07:00
|
|
|
localAddress = "192.168.100.11";
|
2023-04-07 16:50:38 -07:00
|
|
|
# These are the same as above, but for ipv6
|
2023-04-04 22:56:30 -07:00
|
|
|
hostAddress6 = "fc00::1";
|
|
|
|
localAddress6 = "fc00::2";
|
2023-04-05 21:10:58 -07:00
|
|
|
|
|
|
|
# allowed filepaths and container-internal mount points
|
2023-04-07 16:50:38 -07:00
|
|
|
# I believe "hostPath" is the system-wide, non-conatainer path
|
2023-04-05 21:10:58 -07:00
|
|
|
bindMounts = {
|
|
|
|
"/Aurora/nextcloud" = {
|
2023-04-04 22:56:30 -07:00
|
|
|
hostPath = "/Aurora/nextcloud";
|
|
|
|
isReadOnly = false;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2023-04-05 21:10:58 -07:00
|
|
|
# If, when you nix-container root-login and systemctl status nextcloud-setup says the
|
|
|
|
# password files are unreadable, log in as root and `chown nextcloud:nextcloud` the password files
|
|
|
|
config = { config, pkgs, ... }: {
|
2023-04-04 22:56:30 -07:00
|
|
|
|
2023-04-05 21:10:58 -07:00
|
|
|
# A lot of this nextcloud configuration was pulled from this post:
|
|
|
|
# https://jacobneplokh.com/how-to-setup-nextcloud-on-nixos/
|
2023-04-04 22:56:30 -07:00
|
|
|
services.nextcloud = {
|
|
|
|
enable = true;
|
|
|
|
package = pkgs.nextcloud25;
|
2023-04-05 21:10:58 -07:00
|
|
|
enableBrokenCiphersForSSE = false;
|
|
|
|
|
2023-04-07 16:50:38 -07:00
|
|
|
https = true;
|
2023-04-04 22:56:30 -07:00
|
|
|
hostName = "192.168.100.10";
|
2023-04-05 21:10:58 -07:00
|
|
|
home = "/Aurora/nextcloud";
|
|
|
|
|
|
|
|
autoUpdateApps = {
|
|
|
|
enable = true;
|
|
|
|
startAt = "05:00:00";
|
|
|
|
};
|
2023-04-04 22:56:30 -07:00
|
|
|
|
|
|
|
config = {
|
2023-04-07 16:50:38 -07:00
|
|
|
overwriteProtocol = "https";
|
2023-04-04 22:56:30 -07:00
|
|
|
extraTrustedDomains = [
|
2023-04-08 10:48:21 -07:00
|
|
|
"10.0.0.183"
|
2023-04-07 16:50:38 -07:00
|
|
|
"files.nickiel.net"
|
2023-04-04 22:56:30 -07:00
|
|
|
];
|
2023-04-05 21:10:58 -07:00
|
|
|
|
|
|
|
dbtype = "pgsql";
|
|
|
|
dbuser = "nextcloud";
|
|
|
|
dbhost = "/run/postgresql";
|
|
|
|
dbname = "nextcloud";
|
|
|
|
dbpassFile = "/Aurora/nextcloud/nextcloud-db-password";
|
|
|
|
|
|
|
|
# This doesn't seem to be working, see this documation:
|
|
|
|
# https://docs.nextcloud.com/server/latest/admin_manual/configuration_user/reset_admin_password.html
|
|
|
|
adminpassFile = "/Aurora/nextcloud/nextcloud-admin-password";
|
|
|
|
adminuser = "admin";
|
2023-04-04 22:56:30 -07:00
|
|
|
};
|
2023-04-05 21:10:58 -07:00
|
|
|
};
|
2023-04-04 22:56:30 -07:00
|
|
|
|
2023-04-05 21:10:58 -07:00
|
|
|
services.postgresql = {
|
|
|
|
enable = true;
|
|
|
|
ensureDatabases = [ "nextcloud" ];
|
|
|
|
ensureUsers = [
|
|
|
|
{
|
|
|
|
name = "nextcloud";
|
|
|
|
ensurePermissions."DATABASE nextcloud" = "ALL PRIVILEGES";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
authentication = lib.mkForce ''
|
|
|
|
# TYPE DATABASE USER ADDRESS METHOD
|
|
|
|
local all all trust
|
|
|
|
host all all 127.0.0.1/32 trust
|
|
|
|
host all all ::1/128 trust
|
|
|
|
'';
|
|
|
|
};
|
2023-04-04 22:56:30 -07:00
|
|
|
|
2023-04-05 21:10:58 -07:00
|
|
|
# Make sure PostSQL is running before nextcloud
|
|
|
|
systemd.services."nextcloud-setup" = {
|
|
|
|
requires = ["postgresql.service"];
|
|
|
|
after = ["postgresql.service"];
|
2023-04-04 22:56:30 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2023-04-05 21:10:58 -07:00
|
|
|
# Container nixos state configurations
|
|
|
|
system.stateVersion = "22.05";
|
2023-04-04 22:56:30 -07:00
|
|
|
networking.firewall = {
|
|
|
|
enable = true;
|
|
|
|
allowedTCPPorts = [ 80 ];
|
|
|
|
};
|
|
|
|
# Manually configure nameserver. Using resolved inside the container seems to fail
|
|
|
|
# currently
|
2023-04-08 10:48:21 -07:00
|
|
|
environment.etc."resolv.conf".text = "nameserver 1.1.1.1";
|
2023-04-04 22:56:30 -07:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|