X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=modules%2Fprivate%2Fwebsites%2Ftools%2Fcloud%2Fdefault.nix;h=1a0595e3f7099b624e311c8665f7161ca80c8a4b;hb=bbea22c02b6c059a6be1064391f06737ee244ba6;hp=8a42cad9117924664764568eb7882cf66dd3a7bc;hpb=abd7458cbc97f9074f851f07f1f9145344b981ff;p=perso%2FImmae%2FConfig%2FNix.git diff --git a/modules/private/websites/tools/cloud/default.nix b/modules/private/websites/tools/cloud/default.nix index 8a42cad..1a0595e 100644 --- a/modules/private/websites/tools/cloud/default.nix +++ b/modules/private/websites/tools/cloud/default.nix @@ -1,23 +1,28 @@ { lib, pkgs, config, ... }: let - nextcloud = pkgs.webapps.nextcloud.withApps (a: [ + phpPackage = (pkgs.php74.withExtensions({ enabled, all }: enabled ++ [ all.redis all.apcu all.opcache all.imagick ])).override { extraConfig = '' + apc.enable_cli = 1 + ''; + }; + nextcloud = pkgs.webapps.nextcloud_22.withApps (a: [ a.apporder a.audioplayer a.bookmarks a.calendar a.carnet a.contacts - a.cookbook a.deck a.extract a.files_markdown a.files_readmemd + a.cookbook a.deck a.extract a.files_markdown a.files_readmemd a.files_mindmap a.flowupload a.gpxedit a.gpxpod a.keeweb a.maps a.metadata a.music - a.notes a.ocsms a.passman a.polls a.spreed a.tasks + a.notes a.passman a.polls a.spreed a.tasks ]); env = config.myEnv.tools.nextcloud; varDir = "/var/lib/nextcloud"; - webappName = "tools_nextcloud"; - apacheRoot = "/run/current-system/webapps/${webappName}"; cfg = config.myServices.websites.tools.cloud; phpFpm = rec { basedir = builtins.concatStringsSep ":" ([ nextcloud varDir ] ++ nextcloud.apps); pool = { "listen.owner" = "wwwrun"; "listen.group" = "wwwrun"; - "pm" = "ondemand"; + "pm" = "dynamic"; "pm.max_children" = "60"; + "pm.start_servers" = "2"; + "pm.min_spare_servers" = "2"; + "pm.max_spare_servers" = "3"; "pm.process_idle_timeout" = "60"; "php_admin_value[output_buffering]" = "0"; @@ -34,7 +39,8 @@ let "php_admin_value[memory_limit]" = "512M"; "php_admin_value[open_basedir]" = "/run/wrappers/bin/sendmail:${basedir}:/proc/meminfo:/dev/urandom:/proc/self/fd:/tmp"; - "php_admin_value[session.save_path]" = "${varDir}/phpSessions"; + "php_admin_value[session.save_handler]" = "redis"; + "php_admin_value[session.save_path]" = "'unix:///run/redis-php-sessions/redis.sock?persistent=1&prefix=Tools:Nextcloud:'"; }; }; in { @@ -43,17 +49,55 @@ in { }; config = lib.mkIf cfg.enable { + myServices.chatonsProperties.hostings.nextcloud = { + file.datetime = "2022-08-21T19:50:00"; + hosting = { + name = "Nextcloud"; + description = "The self-hosted productivity platform that keeps you in control"; + website = "https://cloud.immae.eu/"; + logo = "https://cloud.immae.eu/core/img/favicon.ico"; + type = "INSTANCE"; + status.level = "OK"; + status.description = "OK"; + registration.load = "OPEN"; + install.type = "PACKAGE"; + }; + }; + myServices.chatonsProperties.services.nextcloud = { + file.datetime = "2022-08-21T19:50:00"; + service = { + name = "Nextcloud"; + description = "The self-hosted productivity platform that keeps you in control"; + website = "https://cloud.immae.eu/"; + logo = "https://cloud.immae.eu/core/img/favicon.ico"; + status.level = "OK"; + status.description = "OK"; + registration."" = ["MEMBER" "CLIENT"]; + registration.load = "OPEN"; + install.type = "PACKAGE"; + guide.user = "https://www.immae.eu/docs/nextcloud.html"; + }; + software = { + name = "Nextcloud"; + website = "https://nextcloud.com/"; + license.url = "https://github.com/nextcloud/server/blob/master/COPYING"; + license.name = "GNU Affero General Public License v3.0"; + version = nextcloud.version; + source.url = "https://github.com/nextcloud/server"; + modules = map (a: a.appName) nextcloud.apps; + }; + }; services.websites.env.tools.modules = [ "proxy_fcgi" ]; services.websites.env.tools.vhostConfs.cloud = { certName = "eldiron"; addToCerts = true; hosts = ["cloud.immae.eu" ]; - root = apacheRoot; + root = nextcloud; extraConfig = [ '' SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1 - + AcceptPathInfo On DirectoryIndex index.php Options FollowSymlinks @@ -73,8 +117,7 @@ in { ]; }; - secrets.keys = [{ - dest = "webapps/tools-nextcloud"; + secrets.keys."webapps/tools-nextcloud" = { user = "wwwrun"; group = "wwwrun"; permissions = "0600"; @@ -100,6 +143,9 @@ in { 'allowZipDownload' => true, 'forcessl' => true, 'theme' => ${"''"}, + 'remember_login_cookie_lifetime' => 60*60*24*30, + 'session_keepalive' => true, + 'session_lifefime' => 60*60*24*30, 'maintenance' => false, 'trusted_domains' => array ( @@ -133,15 +179,15 @@ in { 'has_rebuilt_cache' => true, ); ''; - }]; + }; users.users.root.packages = let occ = pkgs.writeScriptBin "nextcloud-occ" '' #! ${pkgs.stdenv.shell} cd ${nextcloud} NEXTCLOUD_CONFIG_DIR="${nextcloud}/config" \ exec \ - sudo -E -u wwwrun ${pkgs.php74}/bin/php \ - -c ${pkgs.php74}/etc/php.ini \ + sudo -E -u wwwrun ${phpPackage}/bin/php \ + -c ${phpPackage}/etc/php.ini \ occ $* ''; in [ occ ]; @@ -153,24 +199,18 @@ in { in '' install -m 0755 -o wwwrun -g wwwrun -d ${varDir} - install -m 0750 -o wwwrun -g wwwrun -d ${varDir}/phpSessions ${builtins.concatStringsSep "\n" (lib.attrsets.mapAttrsToList (n: v: "install -D -m 0644 -o wwwrun -g wwwrun -T ${v} ${varDir}/config/${n}.json" ) confs)} - #install -D -m 0600 -o wwwrun -g wwwrun -T /var/secrets/webapps/tools-nextcloud ${varDir}/config/config.php + #install -D -m 0600 -o wwwrun -g wwwrun -T ${config.secrets.fullPaths."webapps/tools-nextcloud"} ${varDir}/config/config.php ''; }; - # FIXME: add a warning when config.php changes - system.extraSystemBuilderCmds = '' - mkdir -p $out/webapps - ln -s ${nextcloud} $out/webapps/${webappName} - ''; services.phpfpm.pools.nextcloud = { user = "wwwrun"; group = "wwwrun"; settings = phpFpm.pool; - phpPackage = pkgs.php74.withExtensions({ enabled, all }: enabled ++ [ all.redis all.apcu all.opcache ]); + inherit phpPackage; }; services.cron = { @@ -180,7 +220,7 @@ in { #! ${pkgs.stdenv.shell} export LOCALE_ARCHIVE=/run/current-system/sw/lib/locale/locale-archive export PATH=/run/wrappers/bin:$PATH - ${pkgs.php74}/bin/php -d memory_limit=512M -f ${nextcloud}/cron.php + ${phpPackage}/bin/php -d memory_limit=2048M -f ${nextcloud}/cron.php ''; in [ ''