]>
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 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 | |
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 |
03525bd4 | 120 | $wrapperDir/sudo -u wwwrun ./bin/console --env=prod doctrine:migrations:migrate --no-interaction |
aebd817b IB |
121 | popd > /dev/null |
122 | echo -n "${webappDir}" > ${varDir}/currentWebappDir | |
123 | fi | |
124 | ''; | |
125 | webRoot = "${webappDir}/web"; | |
73ed4b90 IB |
126 | # Domain migration: Table wallabag_entry contains whole |
127 | # https://tools.immae.eu/wallabag domain name in preview_picture | |
a95ab089 | 128 | apache = rec { |
aebd817b IB |
129 | user = "wwwrun"; |
130 | group = "wwwrun"; | |
131 | modules = [ "proxy_fcgi" ]; | |
a95ab089 IB |
132 | webappName = "tools_wallabag"; |
133 | root = "/run/current-system/webapps/${webappName}"; | |
aebd817b | 134 | vhostConf = '' |
a95ab089 IB |
135 | Alias /wallabag "${root}" |
136 | <Directory "${root}"> | |
aebd817b IB |
137 | AllowOverride None |
138 | Require all granted | |
139 | # For OAuth (apps) | |
140 | CGIPassAuth On | |
141 | ||
142 | <FilesMatch "\.php$"> | |
143 | SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost" | |
144 | </FilesMatch> | |
145 | ||
146 | <IfModule mod_rewrite.c> | |
147 | Options -MultiViews | |
148 | RewriteEngine On | |
149 | RewriteCond %{REQUEST_FILENAME} !-f | |
150 | RewriteRule ^(.*)$ app.php [QSA,L] | |
151 | </IfModule> | |
152 | </Directory> | |
a95ab089 | 153 | <Directory "${root}/bundles"> |
aebd817b IB |
154 | <IfModule mod_rewrite.c> |
155 | RewriteEngine Off | |
156 | </IfModule> | |
157 | </Directory> | |
158 | <Directory "${varDir}/assets"> | |
159 | AllowOverride None | |
160 | Require all granted | |
161 | </Directory> | |
162 | ''; | |
163 | }; | |
164 | phpFpm = rec { | |
165 | basedir = builtins.concatStringsSep ":" [ webappDir parameters varDir ]; | |
166 | socket = "/var/run/phpfpm/wallabag.sock"; | |
167 | pool = '' | |
168 | listen = ${socket} | |
169 | user = ${apache.user} | |
170 | group = ${apache.group} | |
171 | listen.owner = ${apache.user} | |
172 | listen.group = ${apache.group} | |
173 | pm = dynamic | |
174 | pm.max_children = 60 | |
175 | pm.start_servers = 2 | |
176 | pm.min_spare_servers = 1 | |
177 | pm.max_spare_servers = 10 | |
178 | ||
179 | ; Needed to avoid clashes in browser cookies (same domain) | |
180 | php_value[session.name] = WallabagPHPSESSID | |
591ebd87 | 181 | php_admin_value[open_basedir] = "/run/wrappers/bin/sendmail:${basedir}:/tmp" |
aebd817b IB |
182 | php_value[max_execution_time] = 300 |
183 | ''; | |
184 | }; | |
185 | }; | |
186 | in | |
187 | wallabag |