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, lib, ... }: {
17 networking.firewall.allowedTCPPorts = [ 80 ];
19 services.nextcloud = {
21 hostName = "nextcloud";
22 package = pkgs.${"nextcloud" + (toString nextcloudVersion)};
28 database.createLocally = true;
32 adminpassFile = toString (pkgs.writeText "admin-pass-file" ''
40 extraAppsEnable = true;
42 inherit (pkgs."nextcloud${lib.versions.major config.services.nextcloud.package.version}Packages".apps) notify_push notes;
44 settings.trusted_proxies = [ "::1" ];
47 services.redis.servers."nextcloud".enable = true;
48 services.redis.servers."nextcloud".port = 6379;
53 configureRedis = pkgs.writeScript "configure-redis" ''
54 #!${pkgs.runtimeShell}
55 nextcloud-occ config:system:set redis 'host' --value 'localhost' --type string
56 nextcloud-occ config:system:set redis 'port' --value 6379 --type integer
57 nextcloud-occ config:system:set memcache.local --value '\OC\Memcache\Redis' --type string
58 nextcloud-occ config:system:set memcache.locking --value '\OC\Memcache\Redis' --type string
60 withRcloneEnv = pkgs.writeScript "with-rclone-env" ''
61 #!${pkgs.runtimeShell}
62 export RCLONE_CONFIG_NEXTCLOUD_TYPE=webdav
63 export RCLONE_CONFIG_NEXTCLOUD_URL="http://nextcloud/remote.php/dav/files/${adminuser}"
64 export RCLONE_CONFIG_NEXTCLOUD_VENDOR="nextcloud"
65 export RCLONE_CONFIG_NEXTCLOUD_USER="${adminuser}"
66 export RCLONE_CONFIG_NEXTCLOUD_PASS="$(${pkgs.rclone}/bin/rclone obscure ${adminpass})"
69 copySharedFile = pkgs.writeScript "copy-shared-file" ''
70 #!${pkgs.runtimeShell}
71 echo 'hi' | ${pkgs.rclone}/bin/rclone rcat nextcloud:test-shared-file
74 diffSharedFile = pkgs.writeScript "diff-shared-file" ''
75 #!${pkgs.runtimeShell}
76 diff <(echo 'hi') <(${pkgs.rclone}/bin/rclone cat nextcloud:test-shared-file)
80 nextcloud.wait_for_unit("multi-user.target")
81 nextcloud.succeed("${configureRedis}")
82 nextcloud.succeed("curl -sSf http://nextcloud/login")
84 "${withRcloneEnv} ${copySharedFile}"
86 client.wait_for_unit("multi-user.target")
87 client.execute("${pkgs.lib.getExe pkgs.nextcloud-notify_push.passthru.test_client} http://nextcloud ${adminuser} ${adminpass} >&2 &")
89 "${withRcloneEnv} ${diffSharedFile}"
91 nextcloud.wait_until_succeeds("journalctl -u nextcloud-notify_push | grep -q \"Sending ping to ${adminuser}\"")
93 # redis cache should not be empty
94 nextcloud.fail('test "[]" = "$(redis-cli --json KEYS "*")"')
96 nextcloud.fail("curl -f http://nextcloud/nix-apps/notes/lib/AppInfo/Application.php")