]> git.immae.eu Git - perso/Immae/Config/Nix.git/commitdiff
Add bakeer’s website
authorIsmaël Bouya <ismael.bouya@normalesup.org>
Mon, 8 Feb 2021 21:27:00 +0000 (22:27 +0100)
committerIsmaël Bouya <ismael.bouya@normalesup.org>
Thu, 11 Feb 2021 20:39:12 +0000 (21:39 +0100)
modules/private/default.nix
modules/private/system/quatresaisons/nextcloud.nix
modules/private/websites/bakeer/cloud.nix [new file with mode: 0644]
modules/private/websites/default.nix
modules/private/websites/tools/cloud/default.nix
nixops/secrets
pkgs/webapps/nextcloud/apps/impersonate.nix [new file with mode: 0644]
pkgs/webapps/nextcloud/default.nix

index b821488dd35ea8ce4e88ebe2d846c03d07f9cb8c..ddc4281cb1c282b81a3914b8ff629fe376c1f6a3 100644 (file)
@@ -19,6 +19,8 @@ set = {
 
 
   # Personal websites
+  bakeerCloud = ./websites/bakeer/cloud.nix;
+
   capitainesLandingPages = ./websites/capitaines/landing_pages.nix;
 
   chloeInte = ./websites/chloe/integration.nix;
index 047d17ebd7b25ef7e46969b308fcfd8eea29a626..89d69d5f0fe5f686d58df1829289d0a15d428cc5 100644 (file)
@@ -95,7 +95,7 @@ in {
         cd ${nextcloud}
         NEXTCLOUD_CONFIG_DIR="${nextcloud}/config" \
           exec \
-          sudo -u wwwrun ${pkgs.php74}/bin/php \
+          sudo -E -u wwwrun ${pkgs.php74}/bin/php \
           -c ${pkgs.php74}/etc/php.ini \
           occ $*
         '';
diff --git a/modules/private/websites/bakeer/cloud.nix b/modules/private/websites/bakeer/cloud.nix
new file mode 100644 (file)
index 0000000..001ca03
--- /dev/null
@@ -0,0 +1,115 @@
+{ lib, pkgs, config,  ... }:
+let
+  cfg = config.myServices.websites.bakeer.cloud;
+  varDir = "/var/lib/nextcloud_farm/bakeer";
+  apacheUser = config.services.httpd.Prod.user;
+  apacheGroup = config.services.httpd.Prod.group;
+  nextcloud = (pkgs.webapps.nextcloud.override { varDir = null; }).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.impersonate a.keeweb a.maps
+    a.metadata a.music a.notes a.ocsms a.passman a.polls a.spreed
+    a.tasks
+  ]);
+  phpBaseDir = builtins.concatStringsSep ":" ([ nextcloud varDir ] ++ nextcloud.apps);
+in {
+  options.myServices.websites.bakeer.cloud.enable = lib.mkEnableOption "enable Bakeer’s cloud";
+
+  config = lib.mkIf cfg.enable {
+    system.activationScripts.bakeer_cloud = {
+      deps = [ "httpd" ];
+      text = ''
+        install -m 0755 -o ${apacheUser} -g ${apacheGroup} -d ${varDir}
+        install -m 0755 -o ${apacheUser} -g ${apacheGroup} -d /var/lib/nextcloud_farm/phpSessions
+        '';
+    };
+    systemd.services.phpfpm-nextcloud_farm.after = lib.mkAfter [ "postgresql.service" ];
+    systemd.services.phpfpm-nextcloud_farm.wants = [ "postgresql.service" ];
+    services.phpfpm.pools.nextcloud_farm = {
+      user = apacheUser;
+      group = apacheGroup;
+      settings = {
+        "listen.owner" = apacheUser;
+        "listen.group" = apacheGroup;
+        "pm" = "ondemand";
+        "pm.max_children" = "60";
+        "pm.process_idle_timeout" = "60";
+
+        "php_admin_value[output_buffering]" = "0";
+        "php_admin_value[max_execution_time]" = "1800";
+        "php_admin_value[zend_extension]" = "opcache";
+        #already enabled by default?
+        #"php_value[opcache.enable]" = "1";
+        "php_value[opcache.enable_cli]" = "1";
+        "php_value[opcache.interned_strings_buffer]" = "8";
+        "php_value[opcache.max_accelerated_files]" = "10000";
+        "php_value[opcache.memory_consumption]" = "128";
+        "php_value[opcache.save_comments]" = "1";
+        "php_value[opcache.revalidate_freq]" = "1";
+        "php_admin_value[memory_limit]" = "512M";
+
+        "php_admin_value[open_basedir]" = "/run/wrappers/bin/sendmail:${phpBaseDir}:/proc/meminfo:/dev/urandom:/proc/self/fd:/tmp";
+        "php_admin_value[session.save_path]" = "/var/lib/nextcloud_farm/phpSessions";
+      };
+      phpPackage = pkgs.php74.withExtensions({ enabled, all }: enabled ++ [ all.redis all.apcu all.opcache ]);
+    };
+    users.users.root.packages = let
+      occ = pkgs.writeScriptBin "nextcloud-occ-bakeer" ''
+        #! ${pkgs.stdenv.shell}
+        cd ${nextcloud}
+        NEXTCLOUD_CONFIG_DIR="${varDir}" \
+          exec \
+          sudo -E -u wwwrun ${pkgs.php74}/bin/php \
+          -c ${pkgs.php74}/etc/php.ini \
+          occ $*
+        '';
+    in [ occ ];
+    services.websites.env.production.modules = [ "proxy_fcgi" ];
+    services.websites.env.production.vhostConfs.bakeer = {
+      certName     = "bakeer";
+      certMainHost = "bakeer.immae.eu";
+      addToCerts   = true;
+      hosts        = ["bakeer.immae.eu" "baxsolution.immae.eu"];
+      root         = nextcloud;
+      extraConfig  = [
+        ''
+          SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
+          SetEnv NEXTCLOUD_CONFIG_DIR "${varDir}"
+          <Directory ${nextcloud}>
+            AcceptPathInfo On
+            DirectoryIndex index.php
+            Options FollowSymlinks
+            Require all granted
+            AllowOverride all
+
+            <IfModule mod_headers.c>
+              Header always set Strict-Transport-Security "max-age=15552000; includeSubDomains; preload"
+            </IfModule>
+            <FilesMatch "\.php$">
+              CGIPassAuth on
+              SetHandler "proxy:unix:${config.services.phpfpm.pools.nextcloud_farm.socket}|fcgi://localhost"
+            </FilesMatch>
+
+          </Directory>
+          ''
+      ];
+    };
+    services.cron = {
+      enable = true;
+      systemCronJobs = let
+        script = pkgs.writeScriptBin "nextcloud-cron" ''
+          #! ${pkgs.stdenv.shell}
+          export LOCALE_ARCHIVE=/run/current-system/sw/lib/locale/locale-archive
+          export PATH=/run/wrappers/bin:$PATH
+          export NEXTCLOUD_CONFIG_DIR="${varDir}"
+          ${pkgs.php74}/bin/php -d memory_limit=512M -f ${nextcloud}/cron.php
+          '';
+      in [
+        ''
+          */15 * * * * wwwrun ${script}/bin/nextcloud-cron
+        ''
+      ];
+    };
+  };
+}
+
index ddfab9abb0332fc0794dd0dab3450fbfb8236541..530db59acad4ac20cb663248b3fccba00be5b22d 100644 (file)
@@ -222,6 +222,7 @@ in
       _theme = pkgs.webapps.apache-theme.theme;
     };
     myServices.websites = {
+      bakeer.cloud.enable = true;
       capitaines.landing_pages.enable = true;
 
       chloe = {
index 1a422966d0864569b75851d606ecb47942db4e4c..8a42cad9117924664764568eb7882cf66dd3a7bc 100644 (file)
@@ -140,7 +140,7 @@ in {
         cd ${nextcloud}
         NEXTCLOUD_CONFIG_DIR="${nextcloud}/config" \
           exec \
-          sudo -u wwwrun ${pkgs.php74}/bin/php \
+          sudo -E -u wwwrun ${pkgs.php74}/bin/php \
           -c ${pkgs.php74}/etc/php.ini \
           occ $*
         '';
index 58ffafe8d341088e117ff2ea4ce7fd33d9d6bc92..6864a6e47101fa922e8d0bca60b9d0ca30803b27 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 58ffafe8d341088e117ff2ea4ce7fd33d9d6bc92
+Subproject commit 6864a6e47101fa922e8d0bca60b9d0ca30803b27
diff --git a/pkgs/webapps/nextcloud/apps/impersonate.nix b/pkgs/webapps/nextcloud/apps/impersonate.nix
new file mode 100644 (file)
index 0000000..66cc893
--- /dev/null
@@ -0,0 +1,9 @@
+{ buildApp, nextcloudVersion }:
+assert nextcloudVersion >= 18 && nextcloudVersion < 19;
+buildApp rec {
+  appName = "impersonate";
+  version = "1.5.2";
+  url = "https://github.com/nextcloud/impersonate/releases/download/v${version}/${appName}.tar.gz";
+  sha256 = "03fm9d2p6ap9gyiw5anmlwsdmiyklrkpdgchfx2zfgxn38pjrz6d";
+}
+
index 1df483a98b4495361f68fd8f415ec15ce5ed9d4e..5017fd23b392b8dfdfb5ddd3cde60b7292c80211 100644 (file)
@@ -3,9 +3,9 @@ let
   appNames = [
     "apporder" "audioplayer" "bookmarks" "calendar" "carnet" "circles"
     "contacts" "cookbook" "deck" "extract" "files_markdown"
-    "files_readmemd" "flowupload" "gpxedit" "gpxpod" "keeweb" "maps"
-    "metadata" "music" "notes" "ocsms" "passman" "polls" "spreed"
-    "social" "tasks"
+    "files_readmemd" "flowupload" "gpxedit" "gpxpod" "impersonate"
+    "keeweb" "maps" "metadata" "music" "notes" "ocsms" "passman" "polls"
+    "spreed" "social" "tasks"
   ];
   allApps = lib.attrsets.genAttrs appNames
     (name: callPackage (./apps + "/${name}.nix") { inherit buildApp nextcloudVersion; });