diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2019-05-07 15:07:00 +0200 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2019-05-07 15:07:00 +0200 |
commit | 79d2de8b83d765721b2cb720b2bc59673df54a4a (patch) | |
tree | db989f06302e31a1468832d106d25d611717e363 /nixops/modules/websites/tools/cloud | |
parent | 86663f1789aecdb62e44a4be46e0ed111b795a09 (diff) | |
download | Nix-79d2de8b83d765721b2cb720b2bc59673df54a4a.tar.gz Nix-79d2de8b83d765721b2cb720b2bc59673df54a4a.tar.zst Nix-79d2de8b83d765721b2cb720b2bc59673df54a4a.zip |
Move directories with only default.nix to standalone file
Diffstat (limited to 'nixops/modules/websites/tools/cloud')
-rw-r--r-- | nixops/modules/websites/tools/cloud/default.nix | 189 |
1 files changed, 0 insertions, 189 deletions
diff --git a/nixops/modules/websites/tools/cloud/default.nix b/nixops/modules/websites/tools/cloud/default.nix deleted file mode 100644 index a7fcd61..0000000 --- a/nixops/modules/websites/tools/cloud/default.nix +++ /dev/null | |||
@@ -1,189 +0,0 @@ | |||
1 | { lib, pkgs, config, myconfig, mylibs, ... }: | ||
2 | let | ||
3 | nextcloud = pkgs.webapps.nextcloud.withApps (builtins.attrValues pkgs.webapps.nextcloud-apps); | ||
4 | env = myconfig.env.tools.nextcloud; | ||
5 | varDir = "/var/lib/nextcloud"; | ||
6 | webappName = "tools_nextcloud"; | ||
7 | apacheRoot = "/run/current-system/webapps/${webappName}"; | ||
8 | cfg = config.services.myWebsites.tools.cloud; | ||
9 | phpFpm = rec { | ||
10 | basedir = builtins.concatStringsSep ":" ( | ||
11 | [ nextcloud varDir ] | ||
12 | ++ builtins.attrValues pkgs.webapps.nextcloud-apps); | ||
13 | socket = "/var/run/phpfpm/nextcloud.sock"; | ||
14 | phpConfig = '' | ||
15 | extension=${pkgs.phpPackages.redis}/lib/php/extensions/redis.so | ||
16 | extension=${pkgs.phpPackages.apcu}/lib/php/extensions/apcu.so | ||
17 | zend_extension=${pkgs.php}/lib/php/extensions/opcache.so | ||
18 | ''; | ||
19 | pool = '' | ||
20 | listen = ${socket} | ||
21 | user = wwwrun | ||
22 | group = wwwrun | ||
23 | listen.owner = wwwrun | ||
24 | listen.group = wwwrun | ||
25 | pm = ondemand | ||
26 | pm.max_children = 60 | ||
27 | pm.process_idle_timeout = 60 | ||
28 | |||
29 | php_admin_value[output_buffering] = 0 | ||
30 | php_admin_value[max_execution_time] = 1800 | ||
31 | php_admin_value[zend_extension] = "opcache" | ||
32 | ;already enabled by default? | ||
33 | ;php_value[opcache.enable] = 1 | ||
34 | php_value[opcache.enable_cli] = 1 | ||
35 | php_value[opcache.interned_strings_buffer] = 8 | ||
36 | php_value[opcache.max_accelerated_files] = 10000 | ||
37 | php_value[opcache.memory_consumption] = 128 | ||
38 | php_value[opcache.save_comments] = 1 | ||
39 | php_value[opcache.revalidate_freq] = 1 | ||
40 | php_admin_value[memory_limit] = 512M | ||
41 | |||
42 | php_admin_value[open_basedir] = "/run/wrappers/bin/sendmail:${basedir}:/proc/meminfo:/dev/urandom:/proc/self/fd:/tmp" | ||
43 | php_admin_value[session.save_path] = "${varDir}/phpSessions" | ||
44 | ''; | ||
45 | }; | ||
46 | in { | ||
47 | options.services.myWebsites.tools.cloud = { | ||
48 | enable = lib.mkEnableOption "enable cloud website"; | ||
49 | }; | ||
50 | |||
51 | config = lib.mkIf cfg.enable { | ||
52 | security.acme.certs."eldiron".extraDomains."cloud.immae.eu" = null; | ||
53 | |||
54 | services.myWebsites.tools.modules = [ "proxy_fcgi" ]; | ||
55 | |||
56 | services.myWebsites.tools.vhostConfs.cloud = { | ||
57 | certName = "eldiron"; | ||
58 | hosts = ["cloud.immae.eu" ]; | ||
59 | root = apacheRoot; | ||
60 | extraConfig = [ | ||
61 | '' | ||
62 | SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1 | ||
63 | <Directory ${apacheRoot}> | ||
64 | AcceptPathInfo On | ||
65 | DirectoryIndex index.php | ||
66 | Options FollowSymlinks | ||
67 | Require all granted | ||
68 | AllowOverride all | ||
69 | |||
70 | <IfModule mod_headers.c> | ||
71 | Header always set Strict-Transport-Security "max-age=15552000; includeSubDomains; preload" | ||
72 | </IfModule> | ||
73 | <FilesMatch "\.php$"> | ||
74 | CGIPassAuth on | ||
75 | SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost" | ||
76 | </FilesMatch> | ||
77 | |||
78 | </Directory> | ||
79 | '' | ||
80 | ]; | ||
81 | }; | ||
82 | |||
83 | mySecrets.keys = [{ | ||
84 | dest = "webapps/tools-nextcloud"; | ||
85 | user = "wwwrun"; | ||
86 | group = "wwwrun"; | ||
87 | permissions = "0600"; | ||
88 | text = '' | ||
89 | <?php | ||
90 | $CONFIG = array ( | ||
91 | // FIXME: change this value when nextcloud starts getting slow | ||
92 | 'instanceid' => '${env.instance_id}1', | ||
93 | 'datadirectory' => '/var/lib/nextcloud/', | ||
94 | 'passwordsalt' => '${env.password_salt}', | ||
95 | 'debug' => false, | ||
96 | 'dbtype' => 'pgsql', | ||
97 | 'version' => '16.0.0.9', | ||
98 | 'dbname' => '${env.postgresql.database}', | ||
99 | 'dbhost' => '${env.postgresql.socket}', | ||
100 | 'dbtableprefix' => 'oc_', | ||
101 | 'dbuser' => '${env.postgresql.user}', | ||
102 | 'dbpassword' => '${env.postgresql.password}', | ||
103 | 'installed' => true, | ||
104 | 'maxZipInputSize' => 0, | ||
105 | 'allowZipDownload' => true, | ||
106 | 'forcessl' => true, | ||
107 | 'theme' => ${"''"}, | ||
108 | 'maintenance' => false, | ||
109 | 'trusted_domains' => | ||
110 | array ( | ||
111 | 0 => 'cloud.immae.eu', | ||
112 | ), | ||
113 | 'secret' => '${env.secret}', | ||
114 | 'appstoreenabled' => false, | ||
115 | 'appstore.experimental.enabled' => true, | ||
116 | 'loglevel' => 2, | ||
117 | 'trashbin_retention_obligation' => 'auto', | ||
118 | 'htaccess.RewriteBase' => '/', | ||
119 | 'mail_smtpmode' => 'sendmail', | ||
120 | 'mail_smtphost' => '127.0.0.1', | ||
121 | 'mail_smtpname' => ''', | ||
122 | 'mail_smtppassword' => ''', | ||
123 | 'mail_from_address' => 'nextcloud', | ||
124 | 'mail_smtpauth' => false, | ||
125 | 'mail_domain' => 'tools.immae.eu', | ||
126 | 'memcache.local' => '\\OC\\Memcache\\APCu', | ||
127 | 'memcache.locking' => '\\OC\\Memcache\\Redis', | ||
128 | 'filelocking.enabled' => true, | ||
129 | 'redis' => | ||
130 | array ( | ||
131 | 'host' => '${env.redis.socket}', | ||
132 | 'port' => 0, | ||
133 | 'dbindex' => ${env.redis.db_index}, | ||
134 | ), | ||
135 | 'overwrite.cli.url' => 'https://cloud.immae.eu', | ||
136 | 'ldapIgnoreNamingRules' => false, | ||
137 | 'ldapProviderFactory' => '\\OCA\\User_LDAP\\LDAPProviderFactory', | ||
138 | 'has_rebuilt_cache' => true, | ||
139 | ); | ||
140 | ''; | ||
141 | }]; | ||
142 | users.users.root.packages = let | ||
143 | occ = pkgs.writeScriptBin "nextcloud-occ" '' | ||
144 | #! ${pkgs.stdenv.shell} | ||
145 | cd ${nextcloud} | ||
146 | NEXTCLOUD_CONFIG_DIR="${nextcloud}/config" \ | ||
147 | exec \ | ||
148 | sudo -u wwwrun ${pkgs.php}/bin/php \ | ||
149 | -c ${pkgs.php}/etc/php.ini \ | ||
150 | occ $* | ||
151 | ''; | ||
152 | in [ occ ]; | ||
153 | |||
154 | system.activationScripts.nextcloud = { | ||
155 | deps = [ "secrets" ]; | ||
156 | text = let | ||
157 | confs = lib.attrsets.mapAttrs (n: v: pkgs.writeText "${n}.json" (builtins.toJSON v)) nextcloud.otherConfig; | ||
158 | in | ||
159 | '' | ||
160 | install -m 0755 -o wwwrun -g wwwrun -d ${varDir} | ||
161 | install -m 0750 -o wwwrun -g wwwrun -d ${varDir}/phpSessions | ||
162 | ${builtins.concatStringsSep "\n" (lib.attrsets.mapAttrsToList (n: v: | ||
163 | "install -D -m 0644 -o wwwrun -g wwwrun -T ${v} ${varDir}/config/${n}.json" | ||
164 | ) confs)} | ||
165 | install -D -m 0600 -o wwwrun -g wwwrun -T /var/secrets/webapps/tools-nextcloud ${varDir}/config/config.php | ||
166 | ''; | ||
167 | }; | ||
168 | # FIXME: add a warning when config.php changes | ||
169 | system.extraSystemBuilderCmds = '' | ||
170 | mkdir -p $out/webapps | ||
171 | ln -s ${nextcloud} $out/webapps/${webappName} | ||
172 | ''; | ||
173 | |||
174 | services.myPhpfpm = { | ||
175 | poolPhpConfigs.nextcloud = phpFpm.phpConfig; | ||
176 | poolConfigs.nextcloud = phpFpm.pool; | ||
177 | }; | ||
178 | |||
179 | services.cron = { | ||
180 | enable = true; | ||
181 | systemCronJobs = [ | ||
182 | '' | ||
183 | LOCALE_ARCHIVE=/run/current-system/sw/lib/locale/locale-archive | ||
184 | */15 * * * * wwwrun ${pkgs.php}/bin/php -f ${nextcloud}/cron.php | ||
185 | '' | ||
186 | ]; | ||
187 | }; | ||
188 | }; | ||
189 | } | ||