at 22.05-pre 3.8 kB view raw
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 config = { 30 dbtype = "mysql"; 31 dbname = "nextcloud"; 32 dbuser = "nextcloud"; 33 dbhost = "127.0.0.1"; 34 dbport = 3306; 35 dbpassFile = "${pkgs.writeText "dbpass" "hunter2" }"; 36 # Don't inherit adminuser since "root" is supposed to be the default 37 adminpassFile = "${pkgs.writeText "adminpass" adminpass}"; # Don't try this at home! 38 }; 39 }; 40 41 services.mysql = { 42 enable = true; 43 bind = "127.0.0.1"; 44 package = pkgs.mariadb; 45 46 # FIXME(@Ma27) Nextcloud isn't compatible with mariadb 10.6, 47 # this is a workaround. 48 # See https://help.nextcloud.com/t/update-to-next-cloud-21-0-2-has-get-an-error/117028/22 49 extraOptions = '' 50 innodb_read_only_compressed=0 51 ''; 52 initialScript = pkgs.writeText "mysql-init" '' 53 CREATE USER 'nextcloud'@'localhost' IDENTIFIED BY 'hunter2'; 54 CREATE DATABASE IF NOT EXISTS nextcloud; 55 GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, 56 CREATE TEMPORARY TABLES ON nextcloud.* TO 'nextcloud'@'localhost' 57 IDENTIFIED BY 'hunter2'; 58 FLUSH privileges; 59 ''; 60 }; 61 62 systemd.services.nextcloud-setup= { 63 requires = ["mysql.service"]; 64 after = ["mysql.service"]; 65 }; 66 67 services.memcached.enable = true; 68 }; 69 }; 70 71 testScript = let 72 configureMemcached = pkgs.writeScript "configure-memcached" '' 73 #!${pkgs.runtimeShell} 74 nextcloud-occ config:system:set memcached_servers 0 0 --value 127.0.0.1 --type string 75 nextcloud-occ config:system:set memcached_servers 0 1 --value 11211 --type integer 76 nextcloud-occ config:system:set memcache.local --value '\OC\Memcache\APCu' --type string 77 nextcloud-occ config:system:set memcache.distributed --value '\OC\Memcache\Memcached' --type string 78 ''; 79 withRcloneEnv = pkgs.writeScript "with-rclone-env" '' 80 #!${pkgs.runtimeShell} 81 export RCLONE_CONFIG_NEXTCLOUD_TYPE=webdav 82 export RCLONE_CONFIG_NEXTCLOUD_URL="http://nextcloud/remote.php/webdav/" 83 export RCLONE_CONFIG_NEXTCLOUD_VENDOR="nextcloud" 84 export RCLONE_CONFIG_NEXTCLOUD_USER="${adminuser}" 85 export RCLONE_CONFIG_NEXTCLOUD_PASS="$(${pkgs.rclone}/bin/rclone obscure ${adminpass})" 86 ''; 87 copySharedFile = pkgs.writeScript "copy-shared-file" '' 88 #!${pkgs.runtimeShell} 89 echo 'hi' | ${pkgs.rclone}/bin/rclone rcat nextcloud:test-shared-file 90 ''; 91 92 diffSharedFile = pkgs.writeScript "diff-shared-file" '' 93 #!${pkgs.runtimeShell} 94 diff <(echo 'hi') <(${pkgs.rclone}/bin/rclone cat nextcloud:test-shared-file) 95 ''; 96 in '' 97 start_all() 98 nextcloud.wait_for_unit("multi-user.target") 99 nextcloud.succeed("${configureMemcached}") 100 nextcloud.succeed("curl -sSf http://nextcloud/login") 101 nextcloud.succeed( 102 "${withRcloneEnv} ${copySharedFile}" 103 ) 104 client.wait_for_unit("multi-user.target") 105 client.succeed( 106 "${withRcloneEnv} ${diffSharedFile}" 107 ) 108 ''; 109})) args