]>
Commit | Line | Data |
---|---|---|
a3d281ea | 1 | { stdenv, fetchurl, writeText, env, composerEnv, phpPackages, php, which }: |
aebd817b IB |
2 | let |
3 | wallabag = rec { | |
4 | varDir = "/var/lib/wallabag"; | |
9d90e7e2 | 5 | parameters = writeText "parameters.yml" '' |
aebd817b IB |
6 | # This file is auto-generated during the composer install |
7 | parameters: | |
8 | database_driver: pdo_pgsql | |
9 | database_driver_class: Wallabag\CoreBundle\Doctrine\DBAL\Driver\CustomPostgreSQLDriver | |
6f4574e7 IB |
10 | database_host: ${env.postgresql.socket} |
11 | database_port: ${env.postgresql.port} | |
12 | database_name: ${env.postgresql.database} | |
13 | database_user: ${env.postgresql.user} | |
9d90e7e2 | 14 | database_password: ${env.postgresql.password} |
aebd817b IB |
15 | database_path: null |
16 | database_table_prefix: wallabag_ | |
17 | database_socket: null | |
18 | database_charset: utf8 | |
19 | domain_name: https://tools.immae.eu/wallabag | |
20 | mailer_transport: smtp | |
21 | mailer_host: mail.immae.eu | |
22 | mailer_user: null | |
23 | mailer_password: null | |
24 | locale: fr | |
9d90e7e2 | 25 | secret: ${env.secret} |
aebd817b IB |
26 | twofactor_auth: true |
27 | twofactor_sender: wallabag@immae.eu | |
28 | fosuser_registration: false | |
29 | fosuser_confirmation: true | |
30 | from_email: wallabag@immae.eu | |
31 | rss_limit: 50 | |
32 | rabbitmq_host: localhost | |
33 | rabbitmq_port: 5672 | |
34 | rabbitmq_user: guest | |
35 | rabbitmq_password: guest | |
36 | rabbitmq_prefetch_count: 10 | |
b0781dbc IB |
37 | redis_scheme: unix |
38 | redis_host: null | |
39 | redis_port: null | |
40 | redis_path: ${env.redis.socket} | |
aebd817b IB |
41 | redis_password: null |
42 | sites_credentials: { } | |
43 | ldap_enabled: true | |
44 | ldap_host: ldap.immae.eu | |
45 | ldap_port: 636 | |
46 | ldap_tls: false | |
47 | ldap_ssl: true | |
48 | ldap_bind_requires_dn: true | |
49 | ldap_base: 'dc=immae,dc=eu' | |
50 | ldap_manager_dn: 'cn=wallabag,ou=services,dc=immae,dc=eu' | |
9d90e7e2 | 51 | ldap_manager_pw: ${env.ldap.password} |
aebd817b IB |
52 | ldap_filter: '(&(memberOf=cn=users,cn=wallabag,ou=services,dc=immae,dc=eu))' |
53 | ldap_admin_filter: '(&(memberOf=cn=admins,cn=wallabag,ou=services,dc=immae,dc=eu)(uid=%s))' | |
54 | ldap_username_attribute: uid | |
55 | ldap_email_attribute: mail | |
56 | ldap_name_attribute: cn | |
57 | ldap_enabled_attribute: null | |
58 | ''; | |
a3d281ea IB |
59 | webappDir = composerEnv.buildPackage rec { |
60 | packages = { | |
61 | "fr3d/ldap-bundle" = { | |
62 | targetDir = ""; | |
63 | src = composerEnv.buildZipPackage { | |
64 | name = "fr3d-ldap-bundle-5a8927c11af45fa06331b97221c6da1a4a237475"; | |
65 | src = fetchurl { | |
66 | url = https://api.github.com/repos/Maks3w/FR3DLdapBundle/zipball/5a8927c11af45fa06331b97221c6da1a4a237475; | |
67 | sha256 = "168zkd82j200wd6h0a3lq81g5s2pifg889rv27q2g429nppsbfxc"; | |
68 | }; | |
69 | }; | |
70 | }; | |
71 | "zendframework/zend-ldap" = { | |
72 | targetDir = ""; | |
73 | src = composerEnv.buildZipPackage { | |
74 | name = "zendframework-zend-ldap-b63c7884a08d3a6bda60ebcf7d6238cf8ad89f49"; | |
75 | src = fetchurl { | |
76 | url = https://api.github.com/repos/zendframework/zend-ldap/zipball/b63c7884a08d3a6bda60ebcf7d6238cf8ad89f49; | |
77 | sha256 = "0mn4yqnb5prqhrbbybmw1i2rx7xf4s4wagbdq9qi55fa0vk3jgw9"; | |
78 | }; | |
79 | }; | |
80 | }; | |
81 | }; | |
82 | noDev = true; | |
83 | doRemoveVendor = false; | |
aebd817b IB |
84 | # Beware when upgrading, I probably messed up with the migrations table |
85 | # (due to a psql bug in wallabag) | |
03525bd4 | 86 | version = "2.3.6"; |
aebd817b IB |
87 | name = "wallabag-${version}"; |
88 | src = fetchurl { | |
89 | url = "https://static.wallabag.org/releases/wallabag-release-${version}.tar.gz"; | |
03525bd4 | 90 | sha256 = "0m0dy3r94ks5pfxyb9vbgrsm0vrwdl3jd5wqwg4f5vd107lq90q1"; |
aebd817b | 91 | }; |
a3d281ea IB |
92 | unpackPhase = '' |
93 | unpackFile "$src" | |
94 | sourceRoot=${version} | |
95 | src=$PWD/${version} | |
96 | ''; | |
aebd817b | 97 | patches = [ ./wallabag_ldap.patch ]; |
a3d281ea IB |
98 | preInstall = '' |
99 | export SYMFONY_ENV="prod" | |
100 | ''; | |
101 | postInstall = '' | |
102 | rm -rf web/assets var/{cache,logs,sessions} app/config/parameters.yml data | |
aebd817b | 103 | ln -sf ${parameters} app/config/parameters.yml |
a3d281ea | 104 | ln -sf ../../../../../../${varDir}/var/{cache,logs,sessions} var |
aebd817b IB |
105 | ln -sf ../../../../../${varDir}/data data |
106 | ln -sf ../../../../../../${varDir}/assets web/assets | |
107 | ''; | |
aebd817b IB |
108 | }; |
109 | activationScript = '' | |
110 | install -m 0755 -o ${apache.user} -g ${apache.group} -d ${varDir} \ | |
111 | ${varDir}/var ${varDir}/data/db ${varDir}/assets/images | |
112 | if [ ! -f "${varDir}/currentWebappDir" -o \ | |
113 | "${webappDir}" != "$(cat ${varDir}/currentWebappDir 2>/dev/null)" ]; then | |
114 | pushd ${webappDir} > /dev/null | |
aebd817b | 115 | $wrapperDir/sudo -u wwwrun ./bin/console --env=prod cache:clear |
03525bd4 | 116 | $wrapperDir/sudo -u wwwrun ./bin/console --env=prod doctrine:migrations:migrate --no-interaction |
aebd817b IB |
117 | popd > /dev/null |
118 | echo -n "${webappDir}" > ${varDir}/currentWebappDir | |
119 | fi | |
120 | ''; | |
121 | webRoot = "${webappDir}/web"; | |
73ed4b90 IB |
122 | # Domain migration: Table wallabag_entry contains whole |
123 | # https://tools.immae.eu/wallabag domain name in preview_picture | |
aebd817b IB |
124 | apache = { |
125 | user = "wwwrun"; | |
126 | group = "wwwrun"; | |
127 | modules = [ "proxy_fcgi" ]; | |
128 | vhostConf = '' | |
aebd817b IB |
129 | Alias /wallabag "${webRoot}" |
130 | <Directory "${webRoot}"> | |
131 | AllowOverride None | |
132 | Require all granted | |
133 | # For OAuth (apps) | |
134 | CGIPassAuth On | |
135 | ||
136 | <FilesMatch "\.php$"> | |
137 | SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost" | |
138 | </FilesMatch> | |
139 | ||
140 | <IfModule mod_rewrite.c> | |
141 | Options -MultiViews | |
142 | RewriteEngine On | |
143 | RewriteCond %{REQUEST_FILENAME} !-f | |
144 | RewriteRule ^(.*)$ app.php [QSA,L] | |
145 | </IfModule> | |
146 | </Directory> | |
147 | <Directory "${webRoot}/bundles"> | |
148 | <IfModule mod_rewrite.c> | |
149 | RewriteEngine Off | |
150 | </IfModule> | |
151 | </Directory> | |
152 | <Directory "${varDir}/assets"> | |
153 | AllowOverride None | |
154 | Require all granted | |
155 | </Directory> | |
156 | ''; | |
157 | }; | |
158 | phpFpm = rec { | |
159 | basedir = builtins.concatStringsSep ":" [ webappDir parameters varDir ]; | |
160 | socket = "/var/run/phpfpm/wallabag.sock"; | |
161 | pool = '' | |
162 | listen = ${socket} | |
163 | user = ${apache.user} | |
164 | group = ${apache.group} | |
165 | listen.owner = ${apache.user} | |
166 | listen.group = ${apache.group} | |
167 | pm = dynamic | |
168 | pm.max_children = 60 | |
169 | pm.start_servers = 2 | |
170 | pm.min_spare_servers = 1 | |
171 | pm.max_spare_servers = 10 | |
172 | ||
173 | ; Needed to avoid clashes in browser cookies (same domain) | |
174 | php_value[session.name] = WallabagPHPSESSID | |
175 | php_admin_value[open_basedir] = "${basedir}:/tmp" | |
176 | php_value[max_execution_time] = 300 | |
177 | ''; | |
178 | }; | |
179 | }; | |
180 | in | |
181 | wallabag |