1 args@{ pkgs, nextcloudVersion ? 22, ... }:
3 (import ../make-test-python.nix ({ pkgs, ...}: let
5 adminuser = "custom-admin-username";
7 name = "nextcloud-with-postgresql-and-redis";
8 meta = with pkgs.lib.maintainers; {
9 maintainers = [ eqyiel ];
13 # The only thing the client needs to do is download a file.
16 nextcloud = { config, pkgs, ... }: {
17 networking.firewall.allowedTCPPorts = [ 80 ];
19 services.nextcloud = {
21 hostName = "nextcloud";
22 package = pkgs.${"nextcloud" + (toString nextcloudVersion)};
32 dbhost = "/run/postgresql";
34 adminpassFile = toString (pkgs.writeText "admin-pass-file" ''
40 services.redis.servers."nextcloud".enable = true;
41 services.redis.servers."nextcloud".port = 6379;
43 systemd.services.nextcloud-setup= {
44 requires = ["postgresql.service"];
50 services.postgresql = {
52 ensureDatabases = [ "nextcloud" ];
55 ensurePermissions."DATABASE nextcloud" = "ALL PRIVILEGES";
63 configureRedis = pkgs.writeScript "configure-redis" ''
64 #!${pkgs.runtimeShell}
65 nextcloud-occ config:system:set redis 'host' --value 'localhost' --type string
66 nextcloud-occ config:system:set redis 'port' --value 6379 --type integer
67 nextcloud-occ config:system:set memcache.local --value '\OC\Memcache\Redis' --type string
68 nextcloud-occ config:system:set memcache.locking --value '\OC\Memcache\Redis' --type string
70 withRcloneEnv = pkgs.writeScript "with-rclone-env" ''
71 #!${pkgs.runtimeShell}
72 export RCLONE_CONFIG_NEXTCLOUD_TYPE=webdav
73 export RCLONE_CONFIG_NEXTCLOUD_URL="http://nextcloud/remote.php/webdav/"
74 export RCLONE_CONFIG_NEXTCLOUD_VENDOR="nextcloud"
75 export RCLONE_CONFIG_NEXTCLOUD_USER="${adminuser}"
76 export RCLONE_CONFIG_NEXTCLOUD_PASS="$(${pkgs.rclone}/bin/rclone obscure ${adminpass})"
79 copySharedFile = pkgs.writeScript "copy-shared-file" ''
80 #!${pkgs.runtimeShell}
81 echo 'hi' | ${pkgs.rclone}/bin/rclone rcat nextcloud:test-shared-file
84 diffSharedFile = pkgs.writeScript "diff-shared-file" ''
85 #!${pkgs.runtimeShell}
86 diff <(echo 'hi') <(${pkgs.rclone}/bin/rclone cat nextcloud:test-shared-file)
90 nextcloud.wait_for_unit("multi-user.target")
91 nextcloud.succeed("${configureRedis}")
92 nextcloud.succeed("curl -sSf http://nextcloud/login")
94 "${withRcloneEnv} ${copySharedFile}"
96 client.wait_for_unit("multi-user.target")
98 "${withRcloneEnv} ${diffSharedFile}"