nixos/nextcloud: fixup #119638
A few minor changes to get #119638 - nextcloud: add option to set datadir and extensions - ready: * `cfg.datadir` now gets `cfg.home` as default to make the type non-nullable. * Enhanced the `basic` test to check the behavior with a custom datadir that's not `/var/lib/nextcloud`. * Fix hashes for apps in option example. * Simplify if/else for `appstoreenable` in override config. * Simplify a few `mapAttrsToList`-expressions in `nextcloud-setup.service`.
This commit is contained in:
parent
7856e40da6
commit
1ee008fcb5
|
@ -5,7 +5,8 @@ with lib;
|
||||||
let
|
let
|
||||||
cfg = config.services.nextcloud;
|
cfg = config.services.nextcloud;
|
||||||
fpm = config.services.phpfpm.pools.nextcloud;
|
fpm = config.services.phpfpm.pools.nextcloud;
|
||||||
datadir = if cfg.datadir == null then "${cfg.home}" else "${cfg.datadir}";
|
|
||||||
|
inherit (cfg) datadir;
|
||||||
|
|
||||||
phpPackage = cfg.phpPackage.buildEnv {
|
phpPackage = cfg.phpPackage.buildEnv {
|
||||||
extensions = { enabled, all }:
|
extensions = { enabled, all }:
|
||||||
|
@ -87,8 +88,8 @@ in {
|
||||||
description = "Storage path of nextcloud.";
|
description = "Storage path of nextcloud.";
|
||||||
};
|
};
|
||||||
datadir = mkOption {
|
datadir = mkOption {
|
||||||
type = types.nullOr types.str;
|
type = types.str;
|
||||||
default = null;
|
defaultText = "config.services.nextcloud.home";
|
||||||
description = ''
|
description = ''
|
||||||
Data storage path of nextcloud. Will be <xref linkend="opt-services.nextcloud.home" /> by default.
|
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).";
|
This folder will be populated with a config.php and data folder which contains the state of the instance (excl the database).";
|
||||||
|
@ -107,13 +108,13 @@ in {
|
||||||
{
|
{
|
||||||
maps = pkgs.fetchNextcloudApp {
|
maps = pkgs.fetchNextcloudApp {
|
||||||
name = "maps";
|
name = "maps";
|
||||||
sha256 = "007y80idqg6b6zk6kjxg4vgw0z8fsxs9lajnv49vv1zjy6jx2i1i+useTheLatestVersion";
|
sha256 = "007y80idqg6b6zk6kjxg4vgw0z8fsxs9lajnv49vv1zjy6jx2i1i";
|
||||||
url = "https://github.com/nextcloud/maps/releases/download/v0.1.9/maps-0.1.9.tar.gz";
|
url = "https://github.com/nextcloud/maps/releases/download/v0.1.9/maps-0.1.9.tar.gz";
|
||||||
version = "0.1.9";
|
version = "0.1.9";
|
||||||
};
|
};
|
||||||
phonetrack = pkgs.fetchNextcloudApp {
|
phonetrack = pkgs.fetchNextcloudApp {
|
||||||
name = "phonetrack";
|
name = "phonetrack";
|
||||||
sha256 = "0qf366vbahyl27p9mshfma1as4nvql6w75zy2zk5xwwbp343vsbc+breakSha";
|
sha256 = "0qf366vbahyl27p9mshfma1as4nvql6w75zy2zk5xwwbp343vsbc";
|
||||||
url = "https://gitlab.com/eneiluj/phonetrack-oc/-/wikis/uploads/931aaaf8dca24bf31a7e169a83c17235/phonetrack-0.6.9.tar.gz";
|
url = "https://gitlab.com/eneiluj/phonetrack-oc/-/wikis/uploads/931aaaf8dca24bf31a7e169a83c17235/phonetrack-0.6.9.tar.gz";
|
||||||
version = "0.6.9";
|
version = "0.6.9";
|
||||||
};
|
};
|
||||||
|
@ -578,6 +579,8 @@ in {
|
||||||
else nextcloud22
|
else nextcloud22
|
||||||
);
|
);
|
||||||
|
|
||||||
|
services.nextcloud.datadir = mkOptionDefault config.services.nextcloud.home;
|
||||||
|
|
||||||
services.nextcloud.phpPackage =
|
services.nextcloud.phpPackage =
|
||||||
if versionOlder cfg.package.version "21" then pkgs.php74
|
if versionOlder cfg.package.version "21" then pkgs.php74
|
||||||
else pkgs.php80;
|
else pkgs.php80;
|
||||||
|
@ -617,6 +620,14 @@ in {
|
||||||
]
|
]
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
showAppStoreSetting = cfg.appstoreEnable != null || cfg.extraApps != {};
|
||||||
|
renderedAppStoreSetting =
|
||||||
|
let
|
||||||
|
x = cfg.appstoreEnable;
|
||||||
|
in
|
||||||
|
if x == null then "false"
|
||||||
|
else boolToString x;
|
||||||
|
|
||||||
overrideConfig = pkgs.writeText "nextcloud-config.php" ''
|
overrideConfig = pkgs.writeText "nextcloud-config.php" ''
|
||||||
<?php
|
<?php
|
||||||
${optionalString requiresReadSecretFunction ''
|
${optionalString requiresReadSecretFunction ''
|
||||||
|
@ -639,11 +650,7 @@ in {
|
||||||
[ 'path' => '${cfg.home}/apps', 'url' => '/apps', 'writable' => false ],
|
[ 'path' => '${cfg.home}/apps', 'url' => '/apps', 'writable' => false ],
|
||||||
[ 'path' => '${cfg.home}/store-apps', 'url' => '/store-apps', 'writable' => true ],
|
[ 'path' => '${cfg.home}/store-apps', 'url' => '/store-apps', 'writable' => true ],
|
||||||
],
|
],
|
||||||
${if (cfg.appstoreEnable != null)
|
${optionalString (showAppStoreSetting) "'appstoreenabled' => ${renderedAppStoreSetting},"}
|
||||||
then '''appstoreenabled' => ${lib.boolToString cfg.appstoreEnable},''
|
|
||||||
else (if (cfg.extraApps != { })
|
|
||||||
then '''appstoreenabled' => false,''
|
|
||||||
else "")}
|
|
||||||
'datadirectory' => '${datadir}/data',
|
'datadirectory' => '${datadir}/data',
|
||||||
'skeletondirectory' => '${cfg.skeletonDirectory}',
|
'skeletondirectory' => '${cfg.skeletonDirectory}',
|
||||||
${optionalString cfg.caching.apcu "'memcache.local' => '\\OC\\Memcache\\APCu',"}
|
${optionalString cfg.caching.apcu "'memcache.local' => '\\OC\\Memcache\\APCu',"}
|
||||||
|
@ -729,10 +736,12 @@ in {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ln -sf ${cfg.package}/apps ${cfg.home}/
|
ln -sf ${cfg.package}/apps ${cfg.home}/
|
||||||
rm -rf ${cfg.home}/nix-apps
|
|
||||||
|
|
||||||
#Install extra apps
|
# Install extra apps
|
||||||
ln -sfT ${pkgs.linkFarm "nix-apps" (lib.mapAttrsToList (name: target: {name=name; path=target;}) cfg.extraApps)} ${cfg.home}/nix-apps
|
ln -sfT \
|
||||||
|
${pkgs.linkFarm "nix-apps"
|
||||||
|
(mapAttrsToList (name: path: { inherit name path; }) cfg.extraApps)} \
|
||||||
|
${cfg.home}/nix-apps
|
||||||
|
|
||||||
# create nextcloud directories.
|
# create nextcloud directories.
|
||||||
# if the directories exist already with wrong permissions, we fix that
|
# if the directories exist already with wrong permissions, we fix that
|
||||||
|
@ -757,7 +766,7 @@ in {
|
||||||
|
|
||||||
${optionalString (cfg.extraAppsEnable && cfg.extraApps != { }) ''
|
${optionalString (cfg.extraAppsEnable && cfg.extraApps != { }) ''
|
||||||
# Try to enable apps (don't fail when one of them cannot be enabled , eg. due to incompatible version)
|
# 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)}
|
${occ}/bin/nextcloud-occ app:enable ${concatStringsSep " " (attrNames cfg.extraApps)}
|
||||||
''}
|
''}
|
||||||
|
|
||||||
${occSetTrustedDomainsCmd}
|
${occSetTrustedDomainsCmd}
|
||||||
|
|
|
@ -33,8 +33,13 @@ in {
|
||||||
in {
|
in {
|
||||||
networking.firewall.allowedTCPPorts = [ 80 ];
|
networking.firewall.allowedTCPPorts = [ 80 ];
|
||||||
|
|
||||||
|
systemd.tmpfiles.rules = [
|
||||||
|
"d /var/lib/nextcloud-data 0750 nextcloud nginx - -"
|
||||||
|
];
|
||||||
|
|
||||||
services.nextcloud = {
|
services.nextcloud = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
datadir = "/var/lib/nextcloud-data";
|
||||||
hostName = "nextcloud";
|
hostName = "nextcloud";
|
||||||
config = {
|
config = {
|
||||||
# Don't inherit adminuser since "root" is supposed to be the default
|
# Don't inherit adminuser since "root" is supposed to be the default
|
||||||
|
@ -98,6 +103,7 @@ in {
|
||||||
"${withRcloneEnv} ${copySharedFile}"
|
"${withRcloneEnv} ${copySharedFile}"
|
||||||
)
|
)
|
||||||
client.wait_for_unit("multi-user.target")
|
client.wait_for_unit("multi-user.target")
|
||||||
|
nextcloud.succeed("test -f /var/lib/nextcloud-data/data/root/files/test-shared-file")
|
||||||
client.succeed(
|
client.succeed(
|
||||||
"${withRcloneEnv} ${diffSharedFile}"
|
"${withRcloneEnv} ${diffSharedFile}"
|
||||||
)
|
)
|
||||||
|
|
|
@ -10,8 +10,7 @@ stdenv.mkDerivation {
|
||||||
inherit version patches;
|
inherit version patches;
|
||||||
|
|
||||||
src = fetchurl {
|
src = fetchurl {
|
||||||
url = url;
|
inherit url sha256;
|
||||||
sha256 = sha256;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
nativeBuildInputs = [
|
nativeBuildInputs = [
|
||||||
|
|
Loading…
Reference in a new issue