|
|
|
@ -5,6 +5,7 @@ with lib; |
|
|
|
|
let |
|
|
|
|
cfg = config.services.nextcloud; |
|
|
|
|
fpm = config.services.phpfpm.pools.nextcloud; |
|
|
|
|
datadir = if cfg.datadir == null then "${cfg.home}" else "${cfg.datadir}"; |
|
|
|
|
|
|
|
|
|
phpPackage = cfg.phpPackage.buildEnv { |
|
|
|
|
extensions = { enabled, all }: |
|
|
|
@ -40,7 +41,7 @@ let |
|
|
|
|
if [[ "$USER" != nextcloud ]]; then |
|
|
|
|
sudo='exec /run/wrappers/bin/sudo -u nextcloud --preserve-env=NEXTCLOUD_CONFIG_DIR --preserve-env=OC_PASS' |
|
|
|
|
fi |
|
|
|
|
export NEXTCLOUD_CONFIG_DIR="${cfg.home}/config" |
|
|
|
|
export NEXTCLOUD_CONFIG_DIR="${datadir}/config" |
|
|
|
|
$sudo \ |
|
|
|
|
${phpPackage}/bin/php \ |
|
|
|
|
occ "$@" |
|
|
|
@ -85,6 +86,15 @@ in { |
|
|
|
|
default = "/var/lib/nextcloud"; |
|
|
|
|
description = "Storage path of nextcloud."; |
|
|
|
|
}; |
|
|
|
|
datadir = mkOption { |
|
|
|
|
type = types.nullOr types.str; |
|
|
|
|
default = null; |
|
|
|
|
description = '' |
|
|
|
|
Data storage path of nextcloud. Will be <xref linkend="opt-services.nextcloud.home" /> by default. |
|
|
|
|
This folder will be populated with a config.php and data folder which contains the state of the instance (excl the database)."; |
|
|
|
|
''; |
|
|
|
|
example = "/mnt/nextcloud-file"; |
|
|
|
|
}; |
|
|
|
|
logLevel = mkOption { |
|
|
|
|
type = types.ints.between 0 4; |
|
|
|
|
default = 2; |
|
|
|
@ -584,7 +594,7 @@ in { |
|
|
|
|
[ 'path' => '${cfg.home}/apps', 'url' => '/apps', 'writable' => false ], |
|
|
|
|
[ 'path' => '${cfg.home}/store-apps', 'url' => '/store-apps', 'writable' => true ], |
|
|
|
|
], |
|
|
|
|
'datadirectory' => '${cfg.home}/data', |
|
|
|
|
'datadirectory' => '${datadir}/data', |
|
|
|
|
'skeletondirectory' => '${cfg.skeletonDirectory}', |
|
|
|
|
${optionalString cfg.caching.apcu "'memcache.local' => '\\OC\\Memcache\\APCu',"} |
|
|
|
|
'log_type' => 'syslog', |
|
|
|
@ -628,7 +638,7 @@ in { |
|
|
|
|
"--database-pass" = "\$${dbpass.arg}"; |
|
|
|
|
"--admin-user" = ''"${c.adminuser}"''; |
|
|
|
|
"--admin-pass" = "\$${adminpass.arg}"; |
|
|
|
|
"--data-dir" = ''"${cfg.home}/data"''; |
|
|
|
|
"--data-dir" = ''"${datadir}/data"''; |
|
|
|
|
}); |
|
|
|
|
in '' |
|
|
|
|
${mkExport dbpass} |
|
|
|
@ -672,7 +682,7 @@ in { |
|
|
|
|
|
|
|
|
|
# create nextcloud directories. |
|
|
|
|
# if the directories exist already with wrong permissions, we fix that |
|
|
|
|
for dir in ${cfg.home}/config ${cfg.home}/data ${cfg.home}/store-apps; do |
|
|
|
|
for dir in ${datadir}/config ${datadir}/data ${cfg.home}/store-apps; do |
|
|
|
|
if [ ! -e $dir ]; then |
|
|
|
|
install -o nextcloud -g nextcloud -d $dir |
|
|
|
|
elif [ $(stat -c "%G" $dir) != "nextcloud" ]; then |
|
|
|
@ -680,23 +690,29 @@ in { |
|
|
|
|
fi |
|
|
|
|
done |
|
|
|
|
|
|
|
|
|
ln -sf ${overrideConfig} ${cfg.home}/config/override.config.php |
|
|
|
|
ln -sf ${overrideConfig} ${datadir}/config/override.config.php |
|
|
|
|
|
|
|
|
|
# Do not install if already installed |
|
|
|
|
if [[ ! -e ${cfg.home}/config/config.php ]]; then |
|
|
|
|
if [[ ! -e ${datadir}/config/config.php ]]; then |
|
|
|
|
${occInstallCmd} |
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
${occ}/bin/nextcloud-occ upgrade |
|
|
|
|
|
|
|
|
|
${occ}/bin/nextcloud-occ config:system:delete trusted_domains |
|
|
|
|
|
|
|
|
|
${optionalString (cfg.extraAppsEnable && cfg.extraApps != { }) '' |
|
|
|
|
# Try to enable apps (don't fail when one of them cannot be enabled , eg. due to incompatible version) |
|
|
|
|
${occ}/bin/nextcloud-occ app:enable ${builtins.concatStringsSep " " ( lib.mapAttrsToList (name: target: "${name}") cfg.extraApps)} || true |
|
|
|
|
''} |
|
|
|
|
|
|
|
|
|
${occSetTrustedDomainsCmd} |
|
|
|
|
''; |
|
|
|
|
serviceConfig.Type = "oneshot"; |
|
|
|
|
serviceConfig.User = "nextcloud"; |
|
|
|
|
}; |
|
|
|
|
nextcloud-cron = { |
|
|
|
|
environment.NEXTCLOUD_CONFIG_DIR = "${cfg.home}/config"; |
|
|
|
|
environment.NEXTCLOUD_CONFIG_DIR = "${datadir}/config"; |
|
|
|
|
serviceConfig.Type = "oneshot"; |
|
|
|
|
serviceConfig.User = "nextcloud"; |
|
|
|
|
serviceConfig.ExecStart = "${phpPackage}/bin/php -f ${cfg.package}/cron.php"; |
|
|
|
@ -715,7 +731,7 @@ in { |
|
|
|
|
group = "nextcloud"; |
|
|
|
|
phpPackage = phpPackage; |
|
|
|
|
phpEnv = { |
|
|
|
|
NEXTCLOUD_CONFIG_DIR = "${cfg.home}/config"; |
|
|
|
|
NEXTCLOUD_CONFIG_DIR = "${datadir}/config"; |
|
|
|
|
PATH = "/run/wrappers/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin:/usr/bin:/bin"; |
|
|
|
|
}; |
|
|
|
|
settings = mapAttrs (name: mkDefault) { |
|
|
|
|