]> git.immae.eu Git - perso/Immae/Config/Nix.git/blob - nixops/modules/websites/tools/tools/default.nix
Add skins for roundcube
[perso/Immae/Config/Nix.git] / nixops / modules / websites / tools / tools / default.nix
1 { lib, pkgs, config, myconfig, mylibs, ... }:
2 let
3 adminer = pkgs.callPackage ../../commons/adminer.nix {};
4 ympd = pkgs.callPackage ./ympd.nix {
5 env = myconfig.env.tools.ympd;
6 };
7 ttrss = pkgs.callPackage ./ttrss.nix {
8 inherit (mylibs) fetchedGithub fetchedGit;
9 env = myconfig.env.tools.ttrss;
10 };
11 roundcubemail = pkgs.callPackage ./roundcubemail.nix {
12 inherit (mylibs) fetchedGithub;
13 env = myconfig.env.tools.roundcubemail;
14 };
15 rainloop = pkgs.callPackage ./rainloop.nix {};
16 kanboard = pkgs.callPackage ./kanboard.nix {
17 inherit (mylibs) fetchedGithub;
18 env = myconfig.env.tools.kanboard;
19 };
20 wallabag = pkgs.callPackage ./wallabag.nix { env = myconfig.env.tools.wallabag; };
21 yourls = pkgs.callPackage ./yourls.nix {
22 inherit (mylibs) fetchedGithub;
23 env = myconfig.env.tools.yourls;
24 };
25 rompr = pkgs.callPackage ./rompr.nix {
26 inherit (mylibs) fetchedGithub;
27 env = myconfig.env.tools.rompr;
28 };
29 shaarli = pkgs.callPackage ./shaarli.nix {
30 env = myconfig.env.tools.shaarli;
31 };
32 dokuwiki = pkgs.callPackage ./dokuwiki.nix {
33 inherit (mylibs) fetchedGithub;
34 };
35 ldap = pkgs.callPackage ./ldap.nix {
36 env = myconfig.env.tools.phpldapadmin;
37 };
38
39 cfg = config.services.myWebsites.tools.tools;
40 in {
41 options.services.myWebsites.tools.tools = {
42 enable = lib.mkEnableOption "enable tools website";
43 };
44
45 config = lib.mkIf cfg.enable {
46 security.acme.certs."eldiron".extraDomains."tools.immae.eu" = null;
47 security.acme.certs."eldiron".extraDomains."devtools.immae.eu" = null;
48
49 services.myWebsites.integration.modules =
50 rainloop.apache.modules;
51
52 services.myWebsites.tools.modules =
53 [ "proxy_fcgi" ]
54 ++ adminer.apache.modules
55 ++ ympd.apache.modules
56 ++ ttrss.apache.modules
57 ++ roundcubemail.apache.modules
58 ++ wallabag.apache.modules
59 ++ yourls.apache.modules
60 ++ rompr.apache.modules
61 ++ shaarli.apache.modules
62 ++ dokuwiki.apache.modules
63 ++ ldap.apache.modules
64 ++ kanboard.apache.modules;
65
66 services.ympd = ympd.config // { enable = true; };
67
68 services.myWebsites.integration.vhostConfs.devtools = {
69 certName = "eldiron";
70 hosts = ["devtools.immae.eu" ];
71 root = null;
72 extraConfig = [
73 rainloop.apache.vhostConf
74 ];
75 };
76
77 services.myWebsites.tools.vhostConfs.tools = {
78 certName = "eldiron";
79 hosts = ["tools.immae.eu" ];
80 root = "/var/lib/ftp/tools.immae.eu";
81 extraConfig = [
82 ''
83 <Directory "/var/lib/ftp/tools.immae.eu">
84 DirectoryIndex index.php index.htm index.html
85 AllowOverride all
86 Require all granted
87 <FilesMatch "\.php$">
88 SetHandler "proxy:unix:/var/run/phpfpm/tools.sock|fcgi://localhost"
89 </FilesMatch>
90 </Directory>
91 ''
92 adminer.apache.vhostConf
93 ympd.apache.vhostConf
94 ttrss.apache.vhostConf
95 roundcubemail.apache.vhostConf
96 wallabag.apache.vhostConf
97 yourls.apache.vhostConf
98 rompr.apache.vhostConf
99 shaarli.apache.vhostConf
100 dokuwiki.apache.vhostConf
101 ldap.apache.vhostConf
102 kanboard.apache.vhostConf
103 ];
104 };
105
106 security.acme.certs."eldiron".extraDomains."outils.immae.eu" = null;
107 services.myWebsites.tools.vhostConfs.outils = {
108 certName = "eldiron";
109 hosts = [ "outils.immae.eu" ];
110 root = null;
111 extraConfig = [
112 ''
113 RedirectMatch 301 ^/mediagoblin(.*)$ https://mgoblin.immae.eu$1
114
115 RedirectMatch 301 ^/ether(.*)$ https://ether.immae.eu$1
116
117 RedirectMatch 301 ^/nextcloud(.*)$ https://cloud.immae.eu$1
118 RedirectMatch 301 ^/owncloud(.*)$ https://cloud.immae.eu$1
119
120 RedirectMatch 301 ^/carddavmate(.*)$ https://dav.immae.eu/infcloud$1
121 RedirectMatch 301 ^/caldavzap(.*)$ https://dav.immae.eu/infcloud$1
122 RedirectMatch 301 ^/caldav.php(.*)$ https://dav.immae.eu/caldav.php$1
123 RedirectMatch 301 ^/davical(.*)$ https://dav.immae.eu/davical$1
124
125 RedirectMatch 301 ^/taskweb(.*)$ https://task.immae.eu/taskweb$1
126
127 RedirectMatch 301 ^/(.*)$ https://tools.immae.eu/$1
128 ''
129 ];
130 };
131
132 services.myPhpfpm.poolConfigs = {
133 adminer = adminer.phpFpm.pool;
134 ttrss = ttrss.phpFpm.pool;
135 roundcubemail = roundcubemail.phpFpm.pool;
136 wallabag = wallabag.phpFpm.pool;
137 yourls = yourls.phpFpm.pool;
138 rompr = rompr.phpFpm.pool;
139 shaarli = shaarli.phpFpm.pool;
140 dokuwiki = dokuwiki.phpFpm.pool;
141 ldap = ldap.phpFpm.pool;
142 rainloop = rainloop.phpFpm.pool;
143 kanboard = kanboard.phpFpm.pool;
144 tools = ''
145 listen = /var/run/phpfpm/tools.sock
146 user = wwwrun
147 group = wwwrun
148 listen.owner = wwwrun
149 listen.group = wwwrun
150 pm = dynamic
151 pm.max_children = 60
152 pm.start_servers = 2
153 pm.min_spare_servers = 1
154 pm.max_spare_servers = 10
155
156 ; Needed to avoid clashes in browser cookies (same domain)
157 php_value[session.name] = ToolsPHPSESSID
158 php_admin_value[open_basedir] = "/run/wrappers/bin/sendmail:/var/lib/ftp/tools.immae.eu:/tmp"
159 '';
160 };
161
162 system.activationScripts = {
163 ttrss = ttrss.activationScript;
164 roundcubemail = roundcubemail.activationScript;
165 wallabag = wallabag.activationScript;
166 yourls = yourls.activationScript;
167 rompr = rompr.activationScript;
168 shaarli = shaarli.activationScript;
169 dokuwiki = dokuwiki.activationScript;
170 rainloop = rainloop.activationScript;
171 kanboard = kanboard.activationScript;
172 };
173
174 system.extraSystemBuilderCmds = ''
175 mkdir -p $out/webapps
176 ln -s ${dokuwiki.webRoot} $out/webapps/${dokuwiki.apache.webappName}
177 ln -s ${ldap.webRoot}/htdocs $out/webapps/${ldap.apache.webappName}
178 ln -s ${rompr.webRoot} $out/webapps/${rompr.apache.webappName}
179 ln -s ${roundcubemail.webRoot} $out/webapps/${roundcubemail.apache.webappName}
180 ln -s ${shaarli.webRoot} $out/webapps/${shaarli.apache.webappName}
181 ln -s ${ttrss.webRoot} $out/webapps/${ttrss.apache.webappName}
182 ln -s ${wallabag.webRoot} $out/webapps/${wallabag.apache.webappName}
183 ln -s ${yourls.webRoot} $out/webapps/${yourls.apache.webappName}
184 ln -s ${rainloop.webRoot} $out/webapps/${rainloop.apache.webappName}
185 ln -s ${kanboard.webRoot} $out/webapps/${kanboard.apache.webappName}
186 '';
187
188 nixpkgs.overlays = [ (self: super: rec {
189 ympd = super.ympd.overrideAttrs(old: mylibs.fetchedGithub ./ympd.json);
190 }) ];
191
192 systemd.services.tt-rss = {
193 description = "Tiny Tiny RSS feeds update daemon";
194 serviceConfig = {
195 User = "wwwrun";
196 ExecStart = "${pkgs.php}/bin/php ${ttrss.webRoot}/update.php --daemon";
197 StandardOutput = "syslog";
198 StandardError = "syslog";
199 PermissionsStartOnly = true;
200 };
201
202 wantedBy = [ "multi-user.target" ];
203 requires = ["postgresql.service"];
204 after = ["network.target" "postgresql.service"];
205 };
206
207 };
208 }
209