diff options
Diffstat (limited to 'modules/private/websites')
-rw-r--r-- | modules/private/websites/bakeer/cloud.nix | 115 | ||||
-rw-r--r-- | modules/private/websites/default.nix | 1 | ||||
-rw-r--r-- | modules/private/websites/tools/cloud/default.nix | 2 |
3 files changed, 117 insertions, 1 deletions
diff --git a/modules/private/websites/bakeer/cloud.nix b/modules/private/websites/bakeer/cloud.nix new file mode 100644 index 0000000..001ca03 --- /dev/null +++ b/modules/private/websites/bakeer/cloud.nix | |||
@@ -0,0 +1,115 @@ | |||
1 | { lib, pkgs, config, ... }: | ||
2 | let | ||
3 | cfg = config.myServices.websites.bakeer.cloud; | ||
4 | varDir = "/var/lib/nextcloud_farm/bakeer"; | ||
5 | apacheUser = config.services.httpd.Prod.user; | ||
6 | apacheGroup = config.services.httpd.Prod.group; | ||
7 | nextcloud = (pkgs.webapps.nextcloud.override { varDir = null; }).withApps (a: [ | ||
8 | a.apporder a.audioplayer a.bookmarks a.calendar a.carnet a.contacts | ||
9 | a.cookbook a.deck a.extract a.files_markdown a.files_readmemd | ||
10 | a.flowupload a.gpxedit a.gpxpod a.impersonate a.keeweb a.maps | ||
11 | a.metadata a.music a.notes a.ocsms a.passman a.polls a.spreed | ||
12 | a.tasks | ||
13 | ]); | ||
14 | phpBaseDir = builtins.concatStringsSep ":" ([ nextcloud varDir ] ++ nextcloud.apps); | ||
15 | in { | ||
16 | options.myServices.websites.bakeer.cloud.enable = lib.mkEnableOption "enable Bakeer’s cloud"; | ||
17 | |||
18 | config = lib.mkIf cfg.enable { | ||
19 | system.activationScripts.bakeer_cloud = { | ||
20 | deps = [ "httpd" ]; | ||
21 | text = '' | ||
22 | install -m 0755 -o ${apacheUser} -g ${apacheGroup} -d ${varDir} | ||
23 | install -m 0755 -o ${apacheUser} -g ${apacheGroup} -d /var/lib/nextcloud_farm/phpSessions | ||
24 | ''; | ||
25 | }; | ||
26 | systemd.services.phpfpm-nextcloud_farm.after = lib.mkAfter [ "postgresql.service" ]; | ||
27 | systemd.services.phpfpm-nextcloud_farm.wants = [ "postgresql.service" ]; | ||
28 | services.phpfpm.pools.nextcloud_farm = { | ||
29 | user = apacheUser; | ||
30 | group = apacheGroup; | ||
31 | settings = { | ||
32 | "listen.owner" = apacheUser; | ||
33 | "listen.group" = apacheGroup; | ||
34 | "pm" = "ondemand"; | ||
35 | "pm.max_children" = "60"; | ||
36 | "pm.process_idle_timeout" = "60"; | ||
37 | |||
38 | "php_admin_value[output_buffering]" = "0"; | ||
39 | "php_admin_value[max_execution_time]" = "1800"; | ||
40 | "php_admin_value[zend_extension]" = "opcache"; | ||
41 | #already enabled by default? | ||
42 | #"php_value[opcache.enable]" = "1"; | ||
43 | "php_value[opcache.enable_cli]" = "1"; | ||
44 | "php_value[opcache.interned_strings_buffer]" = "8"; | ||
45 | "php_value[opcache.max_accelerated_files]" = "10000"; | ||
46 | "php_value[opcache.memory_consumption]" = "128"; | ||
47 | "php_value[opcache.save_comments]" = "1"; | ||
48 | "php_value[opcache.revalidate_freq]" = "1"; | ||
49 | "php_admin_value[memory_limit]" = "512M"; | ||
50 | |||
51 | "php_admin_value[open_basedir]" = "/run/wrappers/bin/sendmail:${phpBaseDir}:/proc/meminfo:/dev/urandom:/proc/self/fd:/tmp"; | ||
52 | "php_admin_value[session.save_path]" = "/var/lib/nextcloud_farm/phpSessions"; | ||
53 | }; | ||
54 | phpPackage = pkgs.php74.withExtensions({ enabled, all }: enabled ++ [ all.redis all.apcu all.opcache ]); | ||
55 | }; | ||
56 | users.users.root.packages = let | ||
57 | occ = pkgs.writeScriptBin "nextcloud-occ-bakeer" '' | ||
58 | #! ${pkgs.stdenv.shell} | ||
59 | cd ${nextcloud} | ||
60 | NEXTCLOUD_CONFIG_DIR="${varDir}" \ | ||
61 | exec \ | ||
62 | sudo -E -u wwwrun ${pkgs.php74}/bin/php \ | ||
63 | -c ${pkgs.php74}/etc/php.ini \ | ||
64 | occ $* | ||
65 | ''; | ||
66 | in [ occ ]; | ||
67 | services.websites.env.production.modules = [ "proxy_fcgi" ]; | ||
68 | services.websites.env.production.vhostConfs.bakeer = { | ||
69 | certName = "bakeer"; | ||
70 | certMainHost = "bakeer.immae.eu"; | ||
71 | addToCerts = true; | ||
72 | hosts = ["bakeer.immae.eu" "baxsolution.immae.eu"]; | ||
73 | root = nextcloud; | ||
74 | extraConfig = [ | ||
75 | '' | ||
76 | SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1 | ||
77 | SetEnv NEXTCLOUD_CONFIG_DIR "${varDir}" | ||
78 | <Directory ${nextcloud}> | ||
79 | AcceptPathInfo On | ||
80 | DirectoryIndex index.php | ||
81 | Options FollowSymlinks | ||
82 | Require all granted | ||
83 | AllowOverride all | ||
84 | |||
85 | <IfModule mod_headers.c> | ||
86 | Header always set Strict-Transport-Security "max-age=15552000; includeSubDomains; preload" | ||
87 | </IfModule> | ||
88 | <FilesMatch "\.php$"> | ||
89 | CGIPassAuth on | ||
90 | SetHandler "proxy:unix:${config.services.phpfpm.pools.nextcloud_farm.socket}|fcgi://localhost" | ||
91 | </FilesMatch> | ||
92 | |||
93 | </Directory> | ||
94 | '' | ||
95 | ]; | ||
96 | }; | ||
97 | services.cron = { | ||
98 | enable = true; | ||
99 | systemCronJobs = let | ||
100 | script = pkgs.writeScriptBin "nextcloud-cron" '' | ||
101 | #! ${pkgs.stdenv.shell} | ||
102 | export LOCALE_ARCHIVE=/run/current-system/sw/lib/locale/locale-archive | ||
103 | export PATH=/run/wrappers/bin:$PATH | ||
104 | export NEXTCLOUD_CONFIG_DIR="${varDir}" | ||
105 | ${pkgs.php74}/bin/php -d memory_limit=512M -f ${nextcloud}/cron.php | ||
106 | ''; | ||
107 | in [ | ||
108 | '' | ||
109 | */15 * * * * wwwrun ${script}/bin/nextcloud-cron | ||
110 | '' | ||
111 | ]; | ||
112 | }; | ||
113 | }; | ||
114 | } | ||
115 | |||
diff --git a/modules/private/websites/default.nix b/modules/private/websites/default.nix index ddfab9a..530db59 100644 --- a/modules/private/websites/default.nix +++ b/modules/private/websites/default.nix | |||
@@ -222,6 +222,7 @@ in | |||
222 | _theme = pkgs.webapps.apache-theme.theme; | 222 | _theme = pkgs.webapps.apache-theme.theme; |
223 | }; | 223 | }; |
224 | myServices.websites = { | 224 | myServices.websites = { |
225 | bakeer.cloud.enable = true; | ||
225 | capitaines.landing_pages.enable = true; | 226 | capitaines.landing_pages.enable = true; |
226 | 227 | ||
227 | chloe = { | 228 | chloe = { |
diff --git a/modules/private/websites/tools/cloud/default.nix b/modules/private/websites/tools/cloud/default.nix index 1a42296..8a42cad 100644 --- a/modules/private/websites/tools/cloud/default.nix +++ b/modules/private/websites/tools/cloud/default.nix | |||
@@ -140,7 +140,7 @@ in { | |||
140 | cd ${nextcloud} | 140 | cd ${nextcloud} |
141 | NEXTCLOUD_CONFIG_DIR="${nextcloud}/config" \ | 141 | NEXTCLOUD_CONFIG_DIR="${nextcloud}/config" \ |
142 | exec \ | 142 | exec \ |
143 | sudo -u wwwrun ${pkgs.php74}/bin/php \ | 143 | sudo -E -u wwwrun ${pkgs.php74}/bin/php \ |
144 | -c ${pkgs.php74}/etc/php.ini \ | 144 | -c ${pkgs.php74}/etc/php.ini \ |
145 | occ $* | 145 | occ $* |
146 | ''; | 146 | ''; |