]> git.immae.eu Git - perso/Immae/Config/Nix.git/blobdiff - modules/private/websites/tools/cloud/default.nix
Add bakeer’s website
[perso/Immae/Config/Nix.git] / modules / private / websites / tools / cloud / default.nix
index 0c6bf0d5ee55dd60c68a3a0137845700c1fd1871..8a42cad9117924664764568eb7882cf66dd3a7bc 100644 (file)
@@ -1,15 +1,18 @@
 { lib, pkgs, config,  ... }:
 let
-  nextcloud = pkgs.webapps.nextcloud.withApps (builtins.attrValues pkgs.webapps.nextcloud-apps);
+  nextcloud = pkgs.webapps.nextcloud.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.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
+  ]);
   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 ]
-      ++ builtins.attrValues pkgs.webapps.nextcloud-apps);
+    basedir = builtins.concatStringsSep ":" ([ nextcloud varDir ] ++ nextcloud.apps);
     pool = {
       "listen.owner" = "wwwrun";
       "listen.group" = "wwwrun";
@@ -33,7 +36,6 @@ let
       "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";
     };
-    phpPackage = pkgs.php72.withExtensions(e: pkgs.php72.enabledExtensions ++ [ e.redis e.apcu e.opcache ]);
   };
 in {
   options.myServices.websites.tools.cloud = {
@@ -41,7 +43,6 @@ in {
   };
 
   config = lib.mkIf cfg.enable {
-    # FIXME: find a way to backup the data
     services.websites.env.tools.modules = [ "proxy_fcgi" ];
 
     services.websites.env.tools.vhostConfs.cloud = {
@@ -77,16 +78,18 @@ in {
       user = "wwwrun";
       group = "wwwrun";
       permissions = "0600";
+      # This file is not actually included, see activationScript below
       text = ''
         <?php
+        include('${nextcloud}/version.php');
         $CONFIG = array (
           // FIXME: change this value when nextcloud starts getting slow
-          'instanceid' => '${env.instance_id}1',
+          'instanceid' => '${env.instance_id}',
           'datadirectory' => '/var/lib/nextcloud/',
           'passwordsalt' => '${env.password_salt}',
           'debug' => false,
           'dbtype' => 'pgsql',
-          'version' => '16.0.0.9',
+          'version' => implode($OC_Version, '.'),
           'dbname' => '${env.postgresql.database}',
           'dbhost' => '${env.postgresql.socket}',
           'dbtableprefix' => 'oc_',
@@ -137,8 +140,8 @@ in {
         cd ${nextcloud}
         NEXTCLOUD_CONFIG_DIR="${nextcloud}/config" \
           exec \
-          sudo -u wwwrun ${pkgs.php72}/bin/php \
-          -c ${pkgs.php72}/etc/php.ini \
+          sudo -E -u wwwrun ${pkgs.php74}/bin/php \
+          -c ${pkgs.php74}/etc/php.ini \
           occ $*
         '';
     in [ occ ];
@@ -154,7 +157,7 @@ in {
         ${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 /var/secrets/webapps/tools-nextcloud ${varDir}/config/config.php
       '';
     };
     # FIXME: add a warning when config.php changes
@@ -167,7 +170,7 @@ in {
       user = "wwwrun";
       group = "wwwrun";
       settings = phpFpm.pool;
-      phpPackage = pkgs.php72.withExtensions(e: pkgs.php72.enabledExtensions ++ [ e.redis e.apcu e.opcache ]);
+      phpPackage = pkgs.php74.withExtensions({ enabled, all }: enabled ++ [ all.redis all.apcu all.opcache ]);
     };
 
     services.cron = {
@@ -177,7 +180,7 @@ in {
           #! ${pkgs.stdenv.shell}
           export LOCALE_ARCHIVE=/run/current-system/sw/lib/locale/locale-archive
           export PATH=/run/wrappers/bin:$PATH
-          ${pkgs.php72}/bin/php -d memory_limit=512M -f ${nextcloud}/cron.php
+          ${pkgs.php74}/bin/php -d memory_limit=512M -f ${nextcloud}/cron.php
           '';
       in [
         ''