]>
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 | |
591ebd87 IB |
20 | mailer_transport: sendmail |
21 | mailer_host: 127.0.0.1 | |
aebd817b IB |
22 | mailer_user: null |
23 | mailer_password: null | |
24 | locale: fr | |
9d90e7e2 | 25 | secret: ${env.secret} |
aebd817b | 26 | twofactor_auth: true |
0f466f6d | 27 | twofactor_sender: wallabag@tools.immae.eu |
aebd817b IB |
28 | fosuser_registration: false |
29 | fosuser_confirmation: true | |
0f466f6d | 30 | from_email: wallabag@tools.immae.eu |
aebd817b IB |
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 | |
591ebd87 IB |
58 | services: |
59 | swiftmailer.mailer.default.transport: | |
60 | class: Swift_SendmailTransport | |
61 | arguments: ['/run/wrappers/bin/sendmail -bs'] | |
aebd817b | 62 | ''; |
a3d281ea IB |
63 | webappDir = composerEnv.buildPackage rec { |
64 | packages = { | |
65 | "fr3d/ldap-bundle" = { | |
66 | targetDir = ""; | |
67 | src = composerEnv.buildZipPackage { | |
68 | name = "fr3d-ldap-bundle-5a8927c11af45fa06331b97221c6da1a4a237475"; | |
69 | src = fetchurl { | |
70 | url = https://api.github.com/repos/Maks3w/FR3DLdapBundle/zipball/5a8927c11af45fa06331b97221c6da1a4a237475; | |
71 | sha256 = "168zkd82j200wd6h0a3lq81g5s2pifg889rv27q2g429nppsbfxc"; | |
72 | }; | |
73 | }; | |
74 | }; | |
75 | "zendframework/zend-ldap" = { | |
76 | targetDir = ""; | |
77 | src = composerEnv.buildZipPackage { | |
78 | name = "zendframework-zend-ldap-b63c7884a08d3a6bda60ebcf7d6238cf8ad89f49"; | |
79 | src = fetchurl { | |
80 | url = https://api.github.com/repos/zendframework/zend-ldap/zipball/b63c7884a08d3a6bda60ebcf7d6238cf8ad89f49; | |
81 | sha256 = "0mn4yqnb5prqhrbbybmw1i2rx7xf4s4wagbdq9qi55fa0vk3jgw9"; | |
82 | }; | |
83 | }; | |
84 | }; | |
85 | }; | |
86 | noDev = true; | |
87 | doRemoveVendor = false; | |
aebd817b IB |
88 | # Beware when upgrading, I probably messed up with the migrations table |
89 | # (due to a psql bug in wallabag) | |
03525bd4 | 90 | version = "2.3.6"; |
aebd817b IB |
91 | name = "wallabag-${version}"; |
92 | src = fetchurl { | |
93 | url = "https://static.wallabag.org/releases/wallabag-release-${version}.tar.gz"; | |
03525bd4 | 94 | sha256 = "0m0dy3r94ks5pfxyb9vbgrsm0vrwdl3jd5wqwg4f5vd107lq90q1"; |
aebd817b | 95 | }; |
a3d281ea IB |
96 | unpackPhase = '' |
97 | unpackFile "$src" | |
98 | sourceRoot=${version} | |
99 | src=$PWD/${version} | |
100 | ''; | |
aebd817b | 101 | patches = [ ./wallabag_ldap.patch ]; |
a3d281ea IB |
102 | preInstall = '' |
103 | export SYMFONY_ENV="prod" | |
104 | ''; | |
105 | postInstall = '' | |
106 | rm -rf web/assets var/{cache,logs,sessions} app/config/parameters.yml data | |
aebd817b | 107 | ln -sf ${parameters} app/config/parameters.yml |
3c8d7f87 IB |
108 | ln -sf ${varDir}/var/{cache,logs,sessions} var |
109 | ln -sf ${varDir}/data data | |
110 | ln -sf ${varDir}/assets web/assets | |
aebd817b | 111 | ''; |
aebd817b IB |
112 | }; |
113 | activationScript = '' | |
114 | install -m 0755 -o ${apache.user} -g ${apache.group} -d ${varDir} \ | |
115 | ${varDir}/var ${varDir}/data/db ${varDir}/assets/images | |
116 | if [ ! -f "${varDir}/currentWebappDir" -o \ | |
117 | "${webappDir}" != "$(cat ${varDir}/currentWebappDir 2>/dev/null)" ]; then | |
118 | pushd ${webappDir} > /dev/null | |
aebd817b | 119 | $wrapperDir/sudo -u wwwrun ./bin/console --env=prod cache:clear |
71daa076 | 120 | rm -rf /var/lib/wallabag/var/cache/pro_ |
03525bd4 | 121 | $wrapperDir/sudo -u wwwrun ./bin/console --env=prod doctrine:migrations:migrate --no-interaction |
aebd817b IB |
122 | popd > /dev/null |
123 | echo -n "${webappDir}" > ${varDir}/currentWebappDir | |
124 | fi | |
125 | ''; | |
126 | webRoot = "${webappDir}/web"; | |
73ed4b90 IB |
127 | # Domain migration: Table wallabag_entry contains whole |
128 | # https://tools.immae.eu/wallabag domain name in preview_picture | |
a95ab089 | 129 | apache = rec { |
aebd817b IB |
130 | user = "wwwrun"; |
131 | group = "wwwrun"; | |
132 | modules = [ "proxy_fcgi" ]; | |
a95ab089 IB |
133 | webappName = "tools_wallabag"; |
134 | root = "/run/current-system/webapps/${webappName}"; | |
aebd817b | 135 | vhostConf = '' |
a95ab089 IB |
136 | Alias /wallabag "${root}" |
137 | <Directory "${root}"> | |
aebd817b IB |
138 | AllowOverride None |
139 | Require all granted | |
140 | # For OAuth (apps) | |
141 | CGIPassAuth On | |
142 | ||
143 | <FilesMatch "\.php$"> | |
144 | SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost" | |
145 | </FilesMatch> | |
146 | ||
147 | <IfModule mod_rewrite.c> | |
148 | Options -MultiViews | |
149 | RewriteEngine On | |
150 | RewriteCond %{REQUEST_FILENAME} !-f | |
151 | RewriteRule ^(.*)$ app.php [QSA,L] | |
152 | </IfModule> | |
153 | </Directory> | |
a95ab089 | 154 | <Directory "${root}/bundles"> |
aebd817b IB |
155 | <IfModule mod_rewrite.c> |
156 | RewriteEngine Off | |
157 | </IfModule> | |
158 | </Directory> | |
159 | <Directory "${varDir}/assets"> | |
160 | AllowOverride None | |
161 | Require all granted | |
162 | </Directory> | |
163 | ''; | |
164 | }; | |
165 | phpFpm = rec { | |
166 | basedir = builtins.concatStringsSep ":" [ webappDir parameters varDir ]; | |
167 | socket = "/var/run/phpfpm/wallabag.sock"; | |
168 | pool = '' | |
169 | listen = ${socket} | |
170 | user = ${apache.user} | |
171 | group = ${apache.group} | |
172 | listen.owner = ${apache.user} | |
173 | listen.group = ${apache.group} | |
174 | pm = dynamic | |
175 | pm.max_children = 60 | |
176 | pm.start_servers = 2 | |
177 | pm.min_spare_servers = 1 | |
178 | pm.max_spare_servers = 10 | |
179 | ||
180 | ; Needed to avoid clashes in browser cookies (same domain) | |
181 | php_value[session.name] = WallabagPHPSESSID | |
591ebd87 | 182 | php_admin_value[open_basedir] = "/run/wrappers/bin/sendmail:${basedir}:/tmp" |
aebd817b IB |
183 | php_value[max_execution_time] = 300 |
184 | ''; | |
185 | }; | |
186 | }; | |
187 | in | |
188 | wallabag |