forked from wurzel/fruitbasket
nextcloud: refactor
- simplify database config - run the whole preStart script as sudo, to reduce log clutter
This commit is contained in:
parent
46040f8d31
commit
91e5639123
1 changed files with 6 additions and 17 deletions
|
@ -12,17 +12,6 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
services = {
|
services = {
|
||||||
postgresql = {
|
|
||||||
enable = true;
|
|
||||||
ensureUsers = [{
|
|
||||||
name = "nextcloud";
|
|
||||||
ensurePermissions = {
|
|
||||||
"DATABASE nextcloud" = "ALL PRIVILEGES";
|
|
||||||
};
|
|
||||||
}];
|
|
||||||
ensureDatabases = [ "nextcloud" ];
|
|
||||||
};
|
|
||||||
|
|
||||||
nextcloud = {
|
nextcloud = {
|
||||||
enable = true;
|
enable = true;
|
||||||
package = pkgs.nextcloud26; # Use current latest nextcloud package
|
package = pkgs.nextcloud26; # Use current latest nextcloud package
|
||||||
|
@ -34,12 +23,10 @@ in
|
||||||
];
|
];
|
||||||
config = {
|
config = {
|
||||||
dbtype = "pgsql";
|
dbtype = "pgsql";
|
||||||
dbuser = "nextcloud";
|
|
||||||
dbhost = "/run/postgresql";
|
|
||||||
dbname = "nextcloud";
|
|
||||||
adminpassFile = config.sops.secrets.nextcloud_adminpass.path;
|
adminpassFile = config.sops.secrets.nextcloud_adminpass.path;
|
||||||
adminuser = "root";
|
adminuser = "root";
|
||||||
};
|
};
|
||||||
|
database.createLocally = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
# Enable ACME and force SSL
|
# Enable ACME and force SSL
|
||||||
|
@ -77,9 +64,7 @@ in
|
||||||
ldapUserFilter = "(|(objectclass=inetOrgPerson))";
|
ldapUserFilter = "(|(objectclass=inetOrgPerson))";
|
||||||
ldapLoginFilter = "(&(|(objectclass=inetOrgPerson))(uid=%uid))";
|
ldapLoginFilter = "(&(|(objectclass=inetOrgPerson))(uid=%uid))";
|
||||||
};
|
};
|
||||||
in
|
preStart = pkgs.writeScript "nextcloud-preStart" ''
|
||||||
{
|
|
||||||
preStart = ''
|
|
||||||
# enable included LDAP app
|
# enable included LDAP app
|
||||||
${occ} app:enable user_ldap
|
${occ} app:enable user_ldap
|
||||||
|
|
||||||
|
@ -92,5 +77,9 @@ in
|
||||||
${lib.concatLines (lib.mapAttrsToList (name: value: "${occ} ldap:set-config s01 '${name}' '${value}'") ldapConfig)}
|
${lib.concatLines (lib.mapAttrsToList (name: value: "${occ} ldap:set-config s01 '${name}' '${value}'") ldapConfig)}
|
||||||
${occ} ldap:set-config s01 'ldapAgentPassword' $(cat ${config.sops.secrets.nextcloud_ldap_search.path})
|
${occ} ldap:set-config s01 'ldapAgentPassword' $(cat ${config.sops.secrets.nextcloud_ldap_search.path})
|
||||||
'';
|
'';
|
||||||
|
in
|
||||||
|
{
|
||||||
|
# run the whole preStart as nextcloud user, so that the log won't be cluttered by lots of sudo calls
|
||||||
|
serviceConfig.ExecStartPre = "/run/wrappers/bin/sudo -u nextcloud --preserve-env=NEXTCLOUD_CONFIG_DIR --preserve-env=OC_PASS ${preStart}";
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue