diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2019-01-01 19:18:08 +0100 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2019-01-01 19:18:08 +0100 |
commit | 940f18341ee8f1e86a18a3488c41b5bbef909cd1 (patch) | |
tree | 77df5726342e3b08757db7c7bd6c4300349308a5 /virtual/packages/nextcloud.nix | |
parent | 66b5bbf6214e8b2f599c394c442638257b149b55 (diff) | |
download | Nix-940f18341ee8f1e86a18a3488c41b5bbef909cd1.tar.gz Nix-940f18341ee8f1e86a18a3488c41b5bbef909cd1.tar.zst Nix-940f18341ee8f1e86a18a3488c41b5bbef909cd1.zip |
Move packages to specific files
Diffstat (limited to 'virtual/packages/nextcloud.nix')
-rw-r--r-- | virtual/packages/nextcloud.nix | 260 |
1 files changed, 260 insertions, 0 deletions
diff --git a/virtual/packages/nextcloud.nix b/virtual/packages/nextcloud.nix new file mode 100644 index 0000000..99130e4 --- /dev/null +++ b/virtual/packages/nextcloud.nix | |||
@@ -0,0 +1,260 @@ | |||
1 | with import ../../libs.nix; | ||
2 | with nixpkgs_unstable; | ||
3 | let | ||
4 | nextcloud = let | ||
5 | # FIXME: initial sync | ||
6 | # FIXME: backup | ||
7 | buildApp = { appName, version, url, sha256, installPhase ? "mkdir -p $out && cp -R . $out/" }: | ||
8 | pkgs.stdenv.mkDerivation rec { | ||
9 | name = "nextcloud-app-${appName}-${version}"; | ||
10 | inherit version; | ||
11 | phases = "unpackPhase installPhase"; | ||
12 | inherit installPhase; | ||
13 | src = fetchurl { inherit url sha256; }; | ||
14 | }; | ||
15 | apps = { | ||
16 | # FIXME: nextcloud complains that he cannot write into config | ||
17 | # directory when an app needs upgrade | ||
18 | # /!\ Attention, just changing the version number is not | ||
19 | # sufficient when the downloaded file doesn’t contain the version | ||
20 | # number in it, sha256 needs to be recomputed | ||
21 | audioplayer = buildApp rec { | ||
22 | appName = "audioplayer"; | ||
23 | version = "2.5.0"; | ||
24 | url = "https://github.com/Rello/${appName}/releases/download/${version}/${appName}-${version}.tar.gz"; | ||
25 | sha256 = "1pg4y51cv3agy28n4gfc8i7x1ya1yijxrmhpblm1n846vhmwdcm8"; | ||
26 | }; | ||
27 | bookmarks = buildApp rec { | ||
28 | appName = "bookmarks"; | ||
29 | version = "0.14.3"; | ||
30 | url = "https://github.com/nextcloud/${appName}/releases/download/v${version}/${appName}-${version}.tar.gz"; | ||
31 | sha256 = "0s7lkcl70izlkihnml1par0cac0wvckllyyga3jkb7k9vdg7d40c"; | ||
32 | }; | ||
33 | calendar = buildApp rec { | ||
34 | appName = "calendar"; | ||
35 | version = "1.6.4"; | ||
36 | url = "https://github.com/nextcloud/${appName}/releases/download/v${version}/${appName}.tar.gz"; | ||
37 | sha256 = "00dijvcvy7snsjslfbyzvpp9anhms22zp1f0zkj89ln33jmana63"; | ||
38 | }; | ||
39 | contacts = buildApp rec { | ||
40 | appName = "contacts"; | ||
41 | version = "3.0.0"; | ||
42 | url = "https://github.com/nextcloud/${appName}/releases/download/v${version}/${appName}.tar.gz"; | ||
43 | sha256 = "0fafy5kgzr5ldr3hxxxgmnw4y3qpjnv5ha1f1dlmqbc65s8frw7s"; | ||
44 | }; | ||
45 | deck = buildApp rec { | ||
46 | appName = "deck"; | ||
47 | version = "0.5.2"; | ||
48 | url = "https://github.com/nextcloud/${appName}/releases/download/v${version}/${appName}.tar.gz"; | ||
49 | sha256 = "1kygzixxdkp3dbma009p3pw0fj8wgcqcv39n7pay78lh6zi3nic7"; | ||
50 | }; | ||
51 | files_markdown = buildApp rec { | ||
52 | appName = "files_markdown"; | ||
53 | version = "2.0.5"; | ||
54 | url = "https://github.com/icewind1991/${appName}/releases/download/v${version}/${appName}.tar.gz"; | ||
55 | sha256 = "1dzvy4c6vff2qmkwqw13dx92xdkafaxgnipswjw44mh0ncc2n9ym"; | ||
56 | }; | ||
57 | gpxedit = buildApp rec { | ||
58 | appName = "gpxedit"; | ||
59 | version = "0.0.10"; | ||
60 | url = "https://gitlab.com/eneiluj/gpxedit-oc/wikis/uploads/33d187268c5f6f6a55350d656305701c/${appName}-${version}.tar.gz"; | ||
61 | sha256 = "0ynpaxm0xhvcj8xax6rm1w0p6j57wbqidhi7bhn268n483gwl2sw"; | ||
62 | }; | ||
63 | gpxpod = buildApp rec { | ||
64 | appName = "gpxpod"; | ||
65 | version = "3.0.0"; | ||
66 | url = "https://gitlab.com/eneiluj/gpxpod-oc/-/archive/v${version}/${appName}-oc-v${version}.tar.gz"; | ||
67 | sha256 = "0smpi4r3z7zfl1612fb30cwm1xmpiq95c81zzqiwzjf288iys74k"; | ||
68 | }; | ||
69 | keeweb = buildApp rec { | ||
70 | appName = "keeweb"; | ||
71 | version = "0.4.0"; | ||
72 | url = "https://github.com/jhass/nextcloud-keeweb/releases/download/v${version}/${appName}-${version}.tar.gz"; | ||
73 | sha256 = "0453kkb0a8vfivmibpwpx4bvhyn64jhns6cdfjacmnvbm6d75nj1"; | ||
74 | }; | ||
75 | notes = buildApp rec { | ||
76 | appName = "notes"; | ||
77 | version = "2.5.1"; | ||
78 | url = "https://github.com/nextcloud/${appName}/releases/download/v${version}/${appName}.tar.gz"; | ||
79 | sha256 = "1albzqqsdirzyw8vhvs7r0qm2wqp8vm9vmxm4crhncd85bk01hmh"; | ||
80 | }; | ||
81 | ocsms = buildApp rec { | ||
82 | appName = "ocsms"; | ||
83 | version = "2.1.0"; | ||
84 | url = "https://github.com/nextcloud/${appName}/releases/download/${version}/${appName}-${version}.tar.gz"; | ||
85 | sha256 = "19xgs82js4sdf6j9478vg9li7za7csvcaa1hbq9nmrq441sbxk9c"; | ||
86 | }; | ||
87 | spreed = buildApp rec { | ||
88 | appName = "spreed"; | ||
89 | version = "5.0.0"; | ||
90 | url = "https://github.com/nextcloud/${appName}/releases/download/v${version}/${appName}-${version}.tar.gz"; | ||
91 | sha256 = "1d48mak1fnf1b28r2687yqamm4pxfg3qyxcj9ny31a6xg2cm0xa7"; | ||
92 | }; | ||
93 | tasks = buildApp rec { | ||
94 | appName = "tasks"; | ||
95 | version = "0.9.8"; | ||
96 | url = "https://github.com/nextcloud/${appName}/releases/download/v${version}/${appName}.tar.gz"; | ||
97 | sha256 = "089m124lfsfk09fqj50x9n7zndq97jp5afgb8s001rpmzym4g6ny"; | ||
98 | }; | ||
99 | }; | ||
100 | in rec { | ||
101 | varDir = "/var/lib/nextcloud"; | ||
102 | config_php = | ||
103 | assert checkEnv "NIXOPS_NEXTCLOUD_PASSWORD_SALT"; | ||
104 | assert checkEnv "NIXOPS_NEXTCLOUD_DB_USER"; | ||
105 | assert checkEnv "NIXOPS_NEXTCLOUD_DB_PASSWORD"; | ||
106 | assert checkEnv "NIXOPS_NEXTCLOUD_INSTANCE_ID"; | ||
107 | assert checkEnv "NIXOPS_NEXTCLOUD_SECRET"; | ||
108 | assert checkEnv "NIXOPS_NEXTCLOUD_REDIS_DB_INDEX"; | ||
109 | pkgs.writeText "config.php" '' | ||
110 | <?php | ||
111 | $CONFIG = array ( | ||
112 | 'instanceid' => '${builtins.getEnv "NIXOPS_NEXTCLOUD_INSTANCE_ID"}', | ||
113 | 'datadirectory' => '/var/lib/nextcloud/', | ||
114 | 'passwordsalt' => '${builtins.getEnv "NIXOPS_NEXTCLOUD_PASSWORD_SALT"}', | ||
115 | 'debug' => false, | ||
116 | 'dbtype' => 'pgsql', | ||
117 | 'version' => '15.0.0.10', | ||
118 | 'dbname' => 'webapps', | ||
119 | 'dbhost' => '/tmp', | ||
120 | 'dbtableprefix' => 'oc_', | ||
121 | 'dbuser' => '${builtins.getEnv "NIXOPS_NEXTCLOUD_DB_USER"}', | ||
122 | 'dbpassword' => '${builtins.getEnv "NIXOPS_NEXTCLOUD_DB_PASSWORD"}', | ||
123 | 'installed' => true, | ||
124 | 'maxZipInputSize' => 0, | ||
125 | 'allowZipDownload' => true, | ||
126 | 'forcessl' => true, | ||
127 | 'theme' => ${"''"}, | ||
128 | 'maintenance' => false, | ||
129 | 'trusted_domains' => | ||
130 | array ( | ||
131 | 0 => 'cloud.immae.eu', | ||
132 | ), | ||
133 | 'secret' => '${builtins.getEnv "NIXOPS_NEXTCLOUD_SECRET"}', | ||
134 | 'appstoreenabled' => false, | ||
135 | 'appstore.experimental.enabled' => true, | ||
136 | 'loglevel' => 0, | ||
137 | 'trashbin_retention_obligation' => 'auto', | ||
138 | 'htaccess.RewriteBase' => '/', | ||
139 | 'mail_smtpmode' => 'smtp', | ||
140 | 'mail_smtphost' => 'mail.immae.eu', | ||
141 | 'mail_smtpname' => ${"''"}, | ||
142 | 'mail_smtppassword' => ${"''"}, | ||
143 | 'mail_from_address' => 'owncloud', | ||
144 | 'mail_smtpauth' => false, | ||
145 | 'mail_domain' => 'immae.eu', | ||
146 | 'memcache.local' => '\\OC\\Memcache\\APCu', | ||
147 | 'memcache.locking' => '\\OC\\Memcache\\Redis', | ||
148 | 'filelocking.enabled' => true, | ||
149 | 'redis' => | ||
150 | array ( | ||
151 | 'host' => 'localhost', | ||
152 | 'port' => 6379, | ||
153 | 'dbindex' => ${builtins.getEnv "NIXOPS_NEXTCLOUD_REDIS_DB_INDEX"}, | ||
154 | ), | ||
155 | 'overwrite.cli.url' => 'https://cloud.immae.eu', | ||
156 | 'ldapIgnoreNamingRules' => false, | ||
157 | 'ldapProviderFactory' => '\\OCA\\User_LDAP\\LDAPProviderFactory', | ||
158 | 'config_is_read_only' => true, | ||
159 | ); | ||
160 | ''; | ||
161 | config = stdenv.mkDerivation rec { | ||
162 | name = "nextcloud-config"; | ||
163 | src = ./nextcloud-config; | ||
164 | phases = "installPhase"; | ||
165 | installPhase = '' | ||
166 | mkdir -p $out | ||
167 | cp -r $src/* $out | ||
168 | cp ${config_php} $out/config.php | ||
169 | ''; | ||
170 | }; | ||
171 | webRoot = stdenv.mkDerivation rec { | ||
172 | name = "nextcloud-${version}"; | ||
173 | version = "15.0.0"; | ||
174 | |||
175 | src = fetchurl { | ||
176 | url = "https://download.nextcloud.com/server/releases/${name}.tar.bz2"; | ||
177 | sha256 = "0y7bk1588n5rmmranmmrkajh50074460hr4v052ahg9mf60wbc2v"; | ||
178 | }; | ||
179 | |||
180 | installPhase = '' | ||
181 | mkdir -p $out/ | ||
182 | cp -R . $out/ | ||
183 | rm -r $out/config | ||
184 | ln -sf ${config} $out/config | ||
185 | ${builtins.concatStringsSep "\n" ( | ||
186 | pkgs.lib.attrsets.mapAttrsToList (name: value: "ln -sf ${value} $out/apps/${name}") apps | ||
187 | )} | ||
188 | ''; | ||
189 | |||
190 | meta = { | ||
191 | description = "Sharing solution for files, calendars, contacts and more"; | ||
192 | homepage = https://nextcloud.com; | ||
193 | maintainers = with stdenv.lib.maintainers; [ schneefux bachp globin fpletz ]; | ||
194 | license = stdenv.lib.licenses.agpl3Plus; | ||
195 | platforms = with stdenv.lib.platforms; unix; | ||
196 | }; | ||
197 | }; | ||
198 | activationScript = { | ||
199 | deps = [ ]; | ||
200 | text = '' | ||
201 | install -m 0755 -o ${apache.user} -g ${apache.group} -d ${varDir} | ||
202 | ''; | ||
203 | }; | ||
204 | apache = { | ||
205 | user = "wwwrun"; | ||
206 | group = "wwwrun"; | ||
207 | modules = [ "proxy_fcgi" ]; | ||
208 | vhostConf = '' | ||
209 | <Directory ${webRoot}> | ||
210 | AcceptPathInfo On | ||
211 | DirectoryIndex index.php | ||
212 | Options FollowSymlinks | ||
213 | Require all granted | ||
214 | AllowOverride all | ||
215 | |||
216 | <IfModule mod_headers.c> | ||
217 | Header always set Strict-Transport-Security "max-age=15552000; includeSubDomains; preload" | ||
218 | </IfModule> | ||
219 | <FilesMatch "\.php$"> | ||
220 | CGIPassAuth on | ||
221 | SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost" | ||
222 | </FilesMatch> | ||
223 | |||
224 | </Directory> | ||
225 | |||
226 | ''; | ||
227 | }; | ||
228 | phpFpm = rec { | ||
229 | basedir = builtins.concatStringsSep ":" ( | ||
230 | [ webRoot varDir config ] | ||
231 | ++ pkgs.lib.attrsets.mapAttrsToList (name: value: value) apps); | ||
232 | socket = "/var/run/phpfpm/nextcloud.sock"; | ||
233 | pool = '' | ||
234 | listen = ${socket} | ||
235 | user = ${apache.user} | ||
236 | group = ${apache.group} | ||
237 | listen.owner = ${apache.user} | ||
238 | listen.group = ${apache.group} | ||
239 | pm = ondemand | ||
240 | pm.max_children = 60 | ||
241 | pm.process_idle_timeout = 60 | ||
242 | |||
243 | php_admin_value[output_buffering] = 0 | ||
244 | php_admin_value[max_execution_time] = 1800 | ||
245 | php_admin_value[zend_extension] = "opcache" | ||
246 | ;php_value[opcache.enable] = 1 | ||
247 | php_value[opcache.enable_cli] = 1 | ||
248 | php_value[opcache.interned_strings_buffer] = 8 | ||
249 | php_value[opcache.max_accelerated_files] = 10000 | ||
250 | php_value[opcache.memory_consumption] = 128 | ||
251 | php_value[opcache.save_comments] = 1 | ||
252 | php_value[opcache.revalidate_freq] = 1 | ||
253 | php_admin_value[memory_limit] = 512M | ||
254 | |||
255 | php_admin_value[open_basedir] = "${basedir}:/proc/meminfo:/dev/urandom:/proc/self/fd:/tmp" | ||
256 | ''; | ||
257 | }; | ||
258 | }; | ||
259 | in | ||
260 | nextcloud | ||