1args@{ pkgs, nextcloudVersion ? 22, ... }:
2
3(import ../make-test-python.nix ({ pkgs, ...}: let
4 adminpass = "hunter2";
5 adminuser = "root";
6in {
7 name = "nextcloud-with-mysql-and-memcached";
8 meta = with pkgs.lib.maintainers; {
9 maintainers = [ eqyiel ];
10 };
11
12 nodes = {
13 # The only thing the client needs to do is download a file.
14 client = { ... }: {};
15
16 nextcloud = { config, pkgs, ... }: {
17 networking.firewall.allowedTCPPorts = [ 80 ];
18
19 services.nextcloud = {
20 enable = true;
21 hostName = "nextcloud";
22 https = true;
23 package = pkgs.${"nextcloud" + (toString nextcloudVersion)};
24 caching = {
25 apcu = true;
26 redis = false;
27 memcached = true;
28 };
29 database.createLocally = true;
30 config = {
31 dbtype = "mysql";
32 # Don't inherit adminuser since "root" is supposed to be the default
33 adminpassFile = "${pkgs.writeText "adminpass" adminpass}"; # Don't try this at home!
34 };
35 };
36
37 services.memcached.enable = true;
38 };
39 };
40
41 testScript = let
42 configureMemcached = pkgs.writeScript "configure-memcached" ''
43 #!${pkgs.runtimeShell}
44 nextcloud-occ config:system:set memcached_servers 0 0 --value 127.0.0.1 --type string
45 nextcloud-occ config:system:set memcached_servers 0 1 --value 11211 --type integer
46 nextcloud-occ config:system:set memcache.local --value '\OC\Memcache\APCu' --type string
47 nextcloud-occ config:system:set memcache.distributed --value '\OC\Memcache\Memcached' --type string
48 '';
49 withRcloneEnv = pkgs.writeScript "with-rclone-env" ''
50 #!${pkgs.runtimeShell}
51 export RCLONE_CONFIG_NEXTCLOUD_TYPE=webdav
52 export RCLONE_CONFIG_NEXTCLOUD_URL="http://nextcloud/remote.php/webdav/"
53 export RCLONE_CONFIG_NEXTCLOUD_VENDOR="nextcloud"
54 export RCLONE_CONFIG_NEXTCLOUD_USER="${adminuser}"
55 export RCLONE_CONFIG_NEXTCLOUD_PASS="$(${pkgs.rclone}/bin/rclone obscure ${adminpass})"
56 '';
57 copySharedFile = pkgs.writeScript "copy-shared-file" ''
58 #!${pkgs.runtimeShell}
59 echo 'hi' | ${pkgs.rclone}/bin/rclone rcat nextcloud:test-shared-file
60 '';
61
62 diffSharedFile = pkgs.writeScript "diff-shared-file" ''
63 #!${pkgs.runtimeShell}
64 diff <(echo 'hi') <(${pkgs.rclone}/bin/rclone cat nextcloud:test-shared-file)
65 '';
66 in ''
67 start_all()
68 nextcloud.wait_for_unit("multi-user.target")
69 nextcloud.succeed("${configureMemcached}")
70 nextcloud.succeed("curl -sSf http://nextcloud/login")
71 nextcloud.succeed(
72 "${withRcloneEnv} ${copySharedFile}"
73 )
74 client.wait_for_unit("multi-user.target")
75 client.succeed(
76 "${withRcloneEnv} ${diffSharedFile}"
77 )
78 '';
79})) args