1 args@{ pkgs, nextcloudVersion ? 22, ... }:
3 (import ../make-test-python.nix ({ pkgs, ...}: let
7 name = "nextcloud-with-mysql-and-memcached";
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";
23 package = pkgs.${"nextcloud" + (toString nextcloudVersion)};
29 database.createLocally = true;
36 dbpassFile = "${pkgs.writeText "dbpass" "hunter2" }";
37 # Don't inherit adminuser since "root" is supposed to be the default
38 adminpassFile = "${pkgs.writeText "adminpass" adminpass}"; # Don't try this at home!
42 systemd.services.nextcloud-setup= {
43 requires = ["mysql.service"];
44 after = ["mysql.service"];
47 services.memcached.enable = true;
52 configureMemcached = pkgs.writeScript "configure-memcached" ''
53 #!${pkgs.runtimeShell}
54 nextcloud-occ config:system:set memcached_servers 0 0 --value 127.0.0.1 --type string
55 nextcloud-occ config:system:set memcached_servers 0 1 --value 11211 --type integer
56 nextcloud-occ config:system:set memcache.local --value '\OC\Memcache\APCu' --type string
57 nextcloud-occ config:system:set memcache.distributed --value '\OC\Memcache\Memcached' --type string
59 withRcloneEnv = pkgs.writeScript "with-rclone-env" ''
60 #!${pkgs.runtimeShell}
61 export RCLONE_CONFIG_NEXTCLOUD_TYPE=webdav
62 export RCLONE_CONFIG_NEXTCLOUD_URL="http://nextcloud/remote.php/webdav/"
63 export RCLONE_CONFIG_NEXTCLOUD_VENDOR="nextcloud"
64 export RCLONE_CONFIG_NEXTCLOUD_USER="${adminuser}"
65 export RCLONE_CONFIG_NEXTCLOUD_PASS="$(${pkgs.rclone}/bin/rclone obscure ${adminpass})"
67 copySharedFile = pkgs.writeScript "copy-shared-file" ''
68 #!${pkgs.runtimeShell}
69 echo 'hi' | ${pkgs.rclone}/bin/rclone rcat nextcloud:test-shared-file
72 diffSharedFile = pkgs.writeScript "diff-shared-file" ''
73 #!${pkgs.runtimeShell}
74 diff <(echo 'hi') <(${pkgs.rclone}/bin/rclone cat nextcloud:test-shared-file)
78 nextcloud.wait_for_unit("multi-user.target")
79 nextcloud.succeed("${configureMemcached}")
80 nextcloud.succeed("curl -sSf http://nextcloud/login")
82 "${withRcloneEnv} ${copySharedFile}"
84 client.wait_for_unit("multi-user.target")
86 "${withRcloneEnv} ${diffSharedFile}"