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