aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2019-05-07 15:19:24 +0200
committerIsmaël Bouya <ismael.bouya@normalesup.org>2019-05-07 15:19:24 +0200
commitfd2d83bd2bf20fafc63daf5041db0151a4b4d17d (patch)
tree596e374d639bcc94ad6619c3e2f317d503e4e485
parente6abbae25ce533e8d38a0e8318b1d5d5a35d813d (diff)
downloadNix-fd2d83bd2bf20fafc63daf5041db0151a4b4d17d.tar.gz
Nix-fd2d83bd2bf20fafc63daf5041db0151a4b4d17d.tar.zst
Nix-fd2d83bd2bf20fafc63daf5041db0151a4b4d17d.zip
Move wallabag to pkgs
-rw-r--r--nixops/modules/websites/tools/tools/default.nix5
-rw-r--r--nixops/modules/websites/tools/tools/wallabag.nix338
-rw-r--r--pkgs/default.nix4
-rw-r--r--pkgs/webapps/default.nix3
-rw-r--r--pkgs/webapps/wallabag/default.nix54
-rw-r--r--pkgs/webapps/wallabag/ldap.patch (renamed from nixops/modules/websites/tools/tools/wallabag_ldap.patch)0
6 files changed, 205 insertions, 199 deletions
diff --git a/nixops/modules/websites/tools/tools/default.nix b/nixops/modules/websites/tools/tools/default.nix
index 22588fb..addb2c3 100644
--- a/nixops/modules/websites/tools/tools/default.nix
+++ b/nixops/modules/websites/tools/tools/default.nix
@@ -16,7 +16,10 @@ let
16 kanboard = pkgs.callPackage ./kanboard.nix { 16 kanboard = pkgs.callPackage ./kanboard.nix {
17 env = myconfig.env.tools.kanboard; 17 env = myconfig.env.tools.kanboard;
18 }; 18 };
19 wallabag = pkgs.callPackage ./wallabag.nix { env = myconfig.env.tools.wallabag; }; 19 wallabag = pkgs.callPackage ./wallabag.nix {
20 inherit (pkgs.webapps) wallabag;
21 env = myconfig.env.tools.wallabag;
22 };
20 yourls = pkgs.callPackage ./yourls.nix { 23 yourls = pkgs.callPackage ./yourls.nix {
21 inherit (pkgs.webapps) yourls yourls-plugins; 24 inherit (pkgs.webapps) yourls yourls-plugins;
22 env = myconfig.env.tools.yourls; 25 env = myconfig.env.tools.yourls;
diff --git a/nixops/modules/websites/tools/tools/wallabag.nix b/nixops/modules/websites/tools/tools/wallabag.nix
index 596b9bc..d6e5882 100644
--- a/nixops/modules/websites/tools/tools/wallabag.nix
+++ b/nixops/modules/websites/tools/tools/wallabag.nix
@@ -1,200 +1,148 @@
1{ stdenv, fetchurl, writeText, env, composerEnv, phpPackages, php, which }: 1{ env, wallabag }:
2let 2rec {
3 wallabag = rec { 3 varDir = "/var/lib/wallabag";
4 varDir = "/var/lib/wallabag"; 4 keys = [{
5 keys = [{ 5 dest = "webapps/tools-wallabag";
6 dest = "webapps/tools-wallabag"; 6 user = apache.user;
7 user = apache.user; 7 group = apache.group;
8 group = apache.group; 8 permissions = "0400";
9 permissions = "0400"; 9 text = ''
10 text = '' 10 # This file is auto-generated during the composer install
11 # This file is auto-generated during the composer install 11 parameters:
12 parameters: 12 database_driver: pdo_pgsql
13 database_driver: pdo_pgsql 13 database_driver_class: Wallabag\CoreBundle\Doctrine\DBAL\Driver\CustomPostgreSQLDriver
14 database_driver_class: Wallabag\CoreBundle\Doctrine\DBAL\Driver\CustomPostgreSQLDriver 14 database_host: ${env.postgresql.socket}
15 database_host: ${env.postgresql.socket} 15 database_port: ${env.postgresql.port}
16 database_port: ${env.postgresql.port} 16 database_name: ${env.postgresql.database}
17 database_name: ${env.postgresql.database} 17 database_user: ${env.postgresql.user}
18 database_user: ${env.postgresql.user} 18 database_password: ${env.postgresql.password}
19 database_password: ${env.postgresql.password} 19 database_path: null
20 database_path: null 20 database_table_prefix: wallabag_
21 database_table_prefix: wallabag_ 21 database_socket: null
22 database_socket: null 22 database_charset: utf8
23 database_charset: utf8 23 domain_name: https://tools.immae.eu/wallabag
24 domain_name: https://tools.immae.eu/wallabag 24 mailer_transport: sendmail
25 mailer_transport: sendmail 25 mailer_host: 127.0.0.1
26 mailer_host: 127.0.0.1 26 mailer_user: null
27 mailer_user: null 27 mailer_password: null
28 mailer_password: null 28 locale: fr
29 locale: fr 29 secret: ${env.secret}
30 secret: ${env.secret} 30 twofactor_auth: true
31 twofactor_auth: true 31 twofactor_sender: wallabag@tools.immae.eu
32 twofactor_sender: wallabag@tools.immae.eu 32 fosuser_registration: false
33 fosuser_registration: false 33 fosuser_confirmation: true
34 fosuser_confirmation: true 34 from_email: wallabag@tools.immae.eu
35 from_email: wallabag@tools.immae.eu 35 rss_limit: 50
36 rss_limit: 50 36 rabbitmq_host: localhost
37 rabbitmq_host: localhost 37 rabbitmq_port: 5672
38 rabbitmq_port: 5672 38 rabbitmq_user: guest
39 rabbitmq_user: guest 39 rabbitmq_password: guest
40 rabbitmq_password: guest 40 rabbitmq_prefetch_count: 10
41 rabbitmq_prefetch_count: 10 41 redis_scheme: unix
42 redis_scheme: unix 42 redis_host: null
43 redis_host: null 43 redis_port: null
44 redis_port: null 44 redis_path: ${env.redis.socket}
45 redis_path: ${env.redis.socket} 45 redis_password: null
46 redis_password: null 46 sites_credentials: { }
47 sites_credentials: { } 47 ldap_enabled: true
48 ldap_enabled: true 48 ldap_host: ldap.immae.eu
49 ldap_host: ldap.immae.eu 49 ldap_port: 636
50 ldap_port: 636 50 ldap_tls: false
51 ldap_tls: false 51 ldap_ssl: true
52 ldap_ssl: true 52 ldap_bind_requires_dn: true
53 ldap_bind_requires_dn: true 53 ldap_base: 'dc=immae,dc=eu'
54 ldap_base: 'dc=immae,dc=eu' 54 ldap_manager_dn: 'cn=wallabag,ou=services,dc=immae,dc=eu'
55 ldap_manager_dn: 'cn=wallabag,ou=services,dc=immae,dc=eu' 55 ldap_manager_pw: ${env.ldap.password}
56 ldap_manager_pw: ${env.ldap.password} 56 ldap_filter: '(&(memberOf=cn=users,cn=wallabag,ou=services,dc=immae,dc=eu))'
57 ldap_filter: '(&(memberOf=cn=users,cn=wallabag,ou=services,dc=immae,dc=eu))' 57 ldap_admin_filter: '(&(memberOf=cn=admins,cn=wallabag,ou=services,dc=immae,dc=eu)(uid=%s))'
58 ldap_admin_filter: '(&(memberOf=cn=admins,cn=wallabag,ou=services,dc=immae,dc=eu)(uid=%s))' 58 ldap_username_attribute: uid
59 ldap_username_attribute: uid 59 ldap_email_attribute: mail
60 ldap_email_attribute: mail 60 ldap_name_attribute: cn
61 ldap_name_attribute: cn 61 ldap_enabled_attribute: null
62 ldap_enabled_attribute: null 62 services:
63 services: 63 swiftmailer.mailer.default.transport:
64 swiftmailer.mailer.default.transport: 64 class: Swift_SendmailTransport
65 class: Swift_SendmailTransport 65 arguments: ['/run/wrappers/bin/sendmail -bs']
66 arguments: ['/run/wrappers/bin/sendmail -bs']
67 '';
68 }];
69 webappDir = composerEnv.buildPackage rec {
70 packages = {
71 "fr3d/ldap-bundle" = {
72 targetDir = "";
73 src = composerEnv.buildZipPackage {
74 name = "fr3d-ldap-bundle-5a8927c11af45fa06331b97221c6da1a4a237475";
75 src = fetchurl {
76 url = https://api.github.com/repos/Maks3w/FR3DLdapBundle/zipball/5a8927c11af45fa06331b97221c6da1a4a237475;
77 sha256 = "168zkd82j200wd6h0a3lq81g5s2pifg889rv27q2g429nppsbfxc";
78 };
79 };
80 };
81 "zendframework/zend-ldap" = {
82 targetDir = "";
83 src = composerEnv.buildZipPackage {
84 name = "zendframework-zend-ldap-b63c7884a08d3a6bda60ebcf7d6238cf8ad89f49";
85 src = fetchurl {
86 url = https://api.github.com/repos/zendframework/zend-ldap/zipball/b63c7884a08d3a6bda60ebcf7d6238cf8ad89f49;
87 sha256 = "0mn4yqnb5prqhrbbybmw1i2rx7xf4s4wagbdq9qi55fa0vk3jgw9";
88 };
89 };
90 };
91 };
92 noDev = true;
93 doRemoveVendor = false;
94 # Beware when upgrading, I probably messed up with the migrations table
95 # (due to a psql bug in wallabag)
96 version = "2.3.6";
97 name = "wallabag-${version}";
98 src = fetchurl {
99 url = "https://static.wallabag.org/releases/wallabag-release-${version}.tar.gz";
100 sha256 = "0m0dy3r94ks5pfxyb9vbgrsm0vrwdl3jd5wqwg4f5vd107lq90q1";
101 };
102 unpackPhase = ''
103 unpackFile "$src"
104 sourceRoot=${version}
105 src=$PWD/${version}
106 '';
107 patches = [ ./wallabag_ldap.patch ];
108 preInstall = ''
109 export SYMFONY_ENV="prod"
110 ''; 66 '';
111 postInstall = '' 67 }];
112 rm -rf web/assets var/{cache,logs,sessions} app/config/parameters.yml data 68 webappDir = wallabag.override { ldap = true; wallabag_config = "/var/secrets/webapps/tools-wallabag"; };
113 ln -sf /var/secrets/webapps/tools-wallabag app/config/parameters.yml 69 activationScript = ''
114 ln -sf ${varDir}/var/{cache,logs,sessions} var 70 install -m 0755 -o ${apache.user} -g ${apache.group} -d ${varDir} \
115 ln -sf ${varDir}/data data 71 ${varDir}/var ${varDir}/data/db ${varDir}/assets/images
116 ln -sf ${varDir}/assets web/assets 72 '';
117 ''; 73 webRoot = "${webappDir}/web";
118 }; 74 # Domain migration: Table wallabag_entry contains whole
119 activationScript = '' 75 # https://tools.immae.eu/wallabag domain name in preview_picture
120 install -m 0755 -o ${apache.user} -g ${apache.group} -d ${varDir} \ 76 apache = rec {
121 ${varDir}/var ${varDir}/data/db ${varDir}/assets/images 77 user = "wwwrun";
122 ''; 78 group = "wwwrun";
123 webRoot = "${webappDir}/web"; 79 modules = [ "proxy_fcgi" ];
124 # Domain migration: Table wallabag_entry contains whole 80 webappName = "tools_wallabag";
125 # https://tools.immae.eu/wallabag domain name in preview_picture 81 root = "/run/current-system/webapps/${webappName}";
126 apache = rec { 82 vhostConf = ''
127 user = "wwwrun"; 83 Alias /wallabag "${root}"
128 group = "wwwrun"; 84 <Directory "${root}">
129 modules = [ "proxy_fcgi" ]; 85 AllowOverride None
130 webappName = "tools_wallabag"; 86 Require all granted
131 root = "/run/current-system/webapps/${webappName}"; 87 # For OAuth (apps)
132 vhostConf = '' 88 CGIPassAuth On
133 Alias /wallabag "${root}"
134 <Directory "${root}">
135 AllowOverride None
136 Require all granted
137 # For OAuth (apps)
138 CGIPassAuth On
139 89
140 <FilesMatch "\.php$"> 90 <FilesMatch "\.php$">
141 SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost" 91 SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost"
142 </FilesMatch> 92 </FilesMatch>
143 93
144 <IfModule mod_rewrite.c> 94 <IfModule mod_rewrite.c>
145 Options -MultiViews 95 Options -MultiViews
146 RewriteEngine On 96 RewriteEngine On
147 RewriteCond %{REQUEST_FILENAME} !-f 97 RewriteCond %{REQUEST_FILENAME} !-f
148 RewriteRule ^(.*)$ app.php [QSA,L] 98 RewriteRule ^(.*)$ app.php [QSA,L]
149 </IfModule> 99 </IfModule>
150 </Directory> 100 </Directory>
151 <Directory "${root}/bundles"> 101 <Directory "${root}/bundles">
152 <IfModule mod_rewrite.c> 102 <IfModule mod_rewrite.c>
153 RewriteEngine Off 103 RewriteEngine Off
154 </IfModule> 104 </IfModule>
155 </Directory> 105 </Directory>
156 <Directory "${varDir}/assets"> 106 <Directory "${varDir}/assets">
157 AllowOverride None 107 AllowOverride None
158 Require all granted 108 Require all granted
159 </Directory> 109 </Directory>
160 ''; 110 '';
161 }; 111 };
162 phpFpm = rec { 112 phpFpm = rec {
163 preStart = '' 113 preStart = ''
164 if [ ! -f "${varDir}/currentWebappDir" -o \ 114 if [ ! -f "${varDir}/currentWebappDir" -o \
165 ! -f "${varDir}/currentKey" -o \ 115 ! -f "${varDir}/currentKey" -o \
166 "${webappDir}" != "$(cat ${varDir}/currentWebappDir 2>/dev/null)" ] \ 116 "${webappDir}" != "$(cat ${varDir}/currentWebappDir 2>/dev/null)" ] \
167 || ! sha512sum -c --status ${varDir}/currentKey; then 117 || ! sha512sum -c --status ${varDir}/currentKey; then
168 pushd ${webappDir} > /dev/null 118 pushd ${webappDir} > /dev/null
169 /run/wrappers/bin/sudo -u wwwrun ./bin/console --env=prod cache:clear 119 /run/wrappers/bin/sudo -u wwwrun ./bin/console --env=prod cache:clear
170 rm -rf /var/lib/wallabag/var/cache/pro_ 120 rm -rf /var/lib/wallabag/var/cache/pro_
171 /run/wrappers/bin/sudo -u wwwrun ./bin/console --env=prod doctrine:migrations:migrate --no-interaction 121 /run/wrappers/bin/sudo -u wwwrun ./bin/console --env=prod doctrine:migrations:migrate --no-interaction
172 popd > /dev/null 122 popd > /dev/null
173 echo -n "${webappDir}" > ${varDir}/currentWebappDir 123 echo -n "${webappDir}" > ${varDir}/currentWebappDir
174 sha512sum /var/secrets/webapps/tools-wallabag > ${varDir}/currentKey 124 sha512sum /var/secrets/webapps/tools-wallabag > ${varDir}/currentKey
175 fi 125 fi
176 ''; 126 '';
177 serviceDeps = [ "postgresql.service" "openldap.service" ]; 127 serviceDeps = [ "postgresql.service" "openldap.service" ];
178 basedir = builtins.concatStringsSep ":" [ webappDir "/var/secrets/webapps/tools-wallabag" varDir ]; 128 basedir = builtins.concatStringsSep ":" [ webappDir "/var/secrets/webapps/tools-wallabag" varDir ];
179 socket = "/var/run/phpfpm/wallabag.sock"; 129 socket = "/var/run/phpfpm/wallabag.sock";
180 pool = '' 130 pool = ''
181 listen = ${socket} 131 listen = ${socket}
182 user = ${apache.user} 132 user = ${apache.user}
183 group = ${apache.group} 133 group = ${apache.group}
184 listen.owner = ${apache.user} 134 listen.owner = ${apache.user}
185 listen.group = ${apache.group} 135 listen.group = ${apache.group}
186 pm = dynamic 136 pm = dynamic
187 pm.max_children = 60 137 pm.max_children = 60
188 pm.start_servers = 2 138 pm.start_servers = 2
189 pm.min_spare_servers = 1 139 pm.min_spare_servers = 1
190 pm.max_spare_servers = 10 140 pm.max_spare_servers = 10
191 141
192 ; Needed to avoid clashes in browser cookies (same domain) 142 ; Needed to avoid clashes in browser cookies (same domain)
193 php_value[session.name] = WallabagPHPSESSID 143 php_value[session.name] = WallabagPHPSESSID
194 php_admin_value[open_basedir] = "/run/wrappers/bin/sendmail:${basedir}:/tmp" 144 php_admin_value[open_basedir] = "/run/wrappers/bin/sendmail:${basedir}:/tmp"
195 php_value[max_execution_time] = 300 145 php_value[max_execution_time] = 300
196 ''; 146 '';
197 };
198 }; 147 };
199in 148}
200 wallabag
diff --git a/pkgs/default.nix b/pkgs/default.nix
index 8a991eb..b97b267 100644
--- a/pkgs/default.nix
+++ b/pkgs/default.nix
@@ -2,7 +2,7 @@
2with pkgs; 2with pkgs;
3let mylibs = import ../libs.nix { inherit pkgs; }; 3let mylibs = import ../libs.nix { inherit pkgs; };
4in 4in
5{ 5rec {
6 boinctui = callPackage ../pkgs/boinctui {}; 6 boinctui = callPackage ../pkgs/boinctui {};
7 cnagios = callPackage ../pkgs/cnagios { inherit mylibs; }; 7 cnagios = callPackage ../pkgs/cnagios { inherit mylibs; };
8 duply = callPackage ../pkgs/duply {}; 8 duply = callPackage ../pkgs/duply {};
@@ -37,5 +37,5 @@ in
37 bitlbee-mastodon = callPackage ./bitlbee-mastodon {}; 37 bitlbee-mastodon = callPackage ./bitlbee-mastodon {};
38 38
39 composerEnv = callPackage ./composer-env {}; 39 composerEnv = callPackage ./composer-env {};
40 webapps = callPackage ./webapps { inherit mylibs; }; 40 webapps = callPackage ./webapps { inherit mylibs composerEnv; };
41} 41}
diff --git a/pkgs/webapps/default.nix b/pkgs/webapps/default.nix
index a4e4f87..8fbb20f 100644
--- a/pkgs/webapps/default.nix
+++ b/pkgs/webapps/default.nix
@@ -1,4 +1,4 @@
1{ callPackage, mylibs, lib }: 1{ callPackage, mylibs, composerEnv, lib }:
2rec { 2rec {
3 adminer = callPackage ./adminer {}; 3 adminer = callPackage ./adminer {};
4 awl = callPackage ./awl {}; 4 awl = callPackage ./awl {};
@@ -80,6 +80,7 @@ rec {
80 ) 80 )
81 ); 81 );
82 82
83 wallabag = callPackage ./wallabag { inherit composerEnv; };
83 yourls = callPackage ./yourls { inherit mylibs; }; 84 yourls = callPackage ./yourls { inherit mylibs; };
84 yourls-with-plugins = yourls.withPlugins (builtins.attrValues yourls-plugins); 85 yourls-with-plugins = yourls.withPlugins (builtins.attrValues yourls-plugins);
85 yourls-plugins = let 86 yourls-plugins = let
diff --git a/pkgs/webapps/wallabag/default.nix b/pkgs/webapps/wallabag/default.nix
new file mode 100644
index 0000000..a437a31
--- /dev/null
+++ b/pkgs/webapps/wallabag/default.nix
@@ -0,0 +1,54 @@
1{ varDir ? "/var/lib/wallabag"
2, wallabag_config ? "/etc/wallabag/parameters.yml"
3, ldap ? false
4, composerEnv, fetchurl, lib }:
5composerEnv.buildPackage rec {
6 packages = {
7 "fr3d/ldap-bundle" = {
8 targetDir = "";
9 src = composerEnv.buildZipPackage {
10 name = "fr3d-ldap-bundle-5a8927c11af45fa06331b97221c6da1a4a237475";
11 src = fetchurl {
12 url = https://api.github.com/repos/Maks3w/FR3DLdapBundle/zipball/5a8927c11af45fa06331b97221c6da1a4a237475;
13 sha256 = "168zkd82j200wd6h0a3lq81g5s2pifg889rv27q2g429nppsbfxc";
14 };
15 };
16 };
17 "zendframework/zend-ldap" = {
18 targetDir = "";
19 src = composerEnv.buildZipPackage {
20 name = "zendframework-zend-ldap-b63c7884a08d3a6bda60ebcf7d6238cf8ad89f49";
21 src = fetchurl {
22 url = https://api.github.com/repos/zendframework/zend-ldap/zipball/b63c7884a08d3a6bda60ebcf7d6238cf8ad89f49;
23 sha256 = "0mn4yqnb5prqhrbbybmw1i2rx7xf4s4wagbdq9qi55fa0vk3jgw9";
24 };
25 };
26 };
27 };
28 noDev = true;
29 doRemoveVendor = false;
30 # Beware when upgrading, I probably messed up with the migrations table
31 # (due to a psql bug in wallabag)
32 version = "2.3.6";
33 name = "wallabag-${version}";
34 src = fetchurl {
35 url = "https://static.wallabag.org/releases/wallabag-release-${version}.tar.gz";
36 sha256 = "0m0dy3r94ks5pfxyb9vbgrsm0vrwdl3jd5wqwg4f5vd107lq90q1";
37 };
38 unpackPhase = ''
39 unpackFile "$src"
40 sourceRoot=${version}
41 src=$PWD/${version}
42 '';
43 patches = lib.optionals ldap [ ./ldap.patch ];
44 preInstall = ''
45 export SYMFONY_ENV="prod"
46 '';
47 postInstall = ''
48 rm -rf web/assets var/{cache,logs,sessions} app/config/parameters.yml data
49 ln -sf ${wallabag_config} app/config/parameters.yml
50 ln -sf ${varDir}/var/{cache,logs,sessions} var
51 ln -sf ${varDir}/data data
52 ln -sf ${varDir}/assets web/assets
53 '';
54}
diff --git a/nixops/modules/websites/tools/tools/wallabag_ldap.patch b/pkgs/webapps/wallabag/ldap.patch
index 9caf7da..9caf7da 100644
--- a/nixops/modules/websites/tools/tools/wallabag_ldap.patch
+++ b/pkgs/webapps/wallabag/ldap.patch