]> git.immae.eu Git - perso/Immae/Config/Nix.git/blob - modules/private/websites/tools/mgoblin/default.nix
Add chatons infos
[perso/Immae/Config/Nix.git] / modules / private / websites / tools / mgoblin / default.nix
1 { lib, pkgs, config, ... }:
2 let
3 env = config.myEnv.tools.mediagoblin;
4 cfg = config.myServices.websites.tools.mediagoblin;
5 mcfg = config.services.mediagoblin;
6 in {
7 options.myServices.websites.tools.mediagoblin = {
8 enable = lib.mkEnableOption "enable mediagoblin's website";
9 };
10
11 config = lib.mkIf cfg.enable {
12 myServices.chatonsProperties.services.mediagoblin = {
13 file.datetime = "2022-08-21T20:00:00";
14 service = {
15 name = "Mediagoblin";
16 description = "MediaGoblin is a free software media publishing platform that anyone can run";
17 website = "https://mgoblin.immae.eu/";
18 logo = "https://mgoblin.immae.eu/mgoblin_static/images/goblin.ico";
19 status.level = "OK";
20 status.description = "OK";
21 registration."" = ["MEMBER" "CLIENT"];
22 registration.load = "OPEN";
23 install.type = "PACKAGE";
24 };
25 software = {
26 name = "Mediagoblin";
27 website = "https://mediagoblin.org/";
28 license.url = "http://www.gnu.org/licenses/agpl.html";
29 license.name = "GNU Affero General Public License";
30 version = mcfg.package.version;
31 source.url = "https://git.savannah.gnu.org/git/mediagoblin.git";
32 modules = map (a: a.pluginName) mcfg.package.plugins;
33 };
34 };
35 secrets.keys."webapps/tools-mediagoblin" = {
36 user = "mediagoblin";
37 group = "mediagoblin";
38 permissions = "0400";
39 text =
40 let
41 psql_url = with env.postgresql; "postgresql://${user}:${password}@:${port}/${database}?host=${socket}";
42 redis_url = with env.redis; "redis+socket://${socket}?virtual_host=${db}";
43 in
44 ''
45 [DEFAULT]
46 data_basedir = "${mcfg.dataDir}"
47
48 [mediagoblin]
49 direct_remote_path = /mgoblin_static/
50 email_sender_address = "mediagoblin@tools.immae.eu"
51
52 #sql_engine = sqlite:///%(data_basedir)s/mediagoblin.db
53 sql_engine = ${psql_url}
54
55 email_debug_mode = false
56 allow_registration = false
57 allow_reporting = true
58
59 theme = airymodified
60
61 user_privilege_scheme = "uploader,commenter,reporter"
62
63 # We need to redefine them here since we override data_basedir
64 # cf /usr/share/webapps/mediagoblin/mediagoblin/config_spec.ini
65 workbench_path = %(data_basedir)s/media/workbench
66 crypto_path = %(data_basedir)s/crypto
67 theme_install_dir = %(data_basedir)s/themes/
68 theme_linked_assets_dir = %(data_basedir)s/theme_static/
69 plugin_linked_assets_dir = %(data_basedir)s/plugin_static/
70
71 [storage:queuestore]
72 base_dir = %(data_basedir)s/media/queue
73
74 [storage:publicstore]
75 base_dir = %(data_basedir)s/media/public
76 base_url = /mgoblin_media/
77
78 [celery]
79 CELERY_RESULT_DBURI = ${redis_url}
80 BROKER_URL = ${redis_url}
81 CELERYD_CONCURRENCY = 1
82
83 [plugins]
84 [[mediagoblin.plugins.geolocation]]
85 [[mediagoblin.plugins.ldap]]
86 [[[immae.eu]]]
87 LDAP_SERVER_URI = 'ldaps://${env.ldap.host}:636'
88 LDAP_SEARCH_BASE = '${env.ldap.base}'
89 LDAP_BIND_DN = '${env.ldap.dn}'
90 LDAP_BIND_PW = '${env.ldap.password}'
91 LDAP_SEARCH_FILTER = '${env.ldap.filter}'
92 EMAIL_SEARCH_FIELD = 'mail'
93 [[mediagoblin.plugins.basicsearch]]
94 [[mediagoblin.plugins.piwigo]]
95 [[mediagoblin.plugins.processing_info]]
96 [[mediagoblin.media_types.image]]
97 [[mediagoblin.media_types.video]]
98 '';
99 };
100
101 users.users.mediagoblin.extraGroups = [ "keys" ];
102
103 services.mediagoblin = {
104 enable = true;
105 package = pkgs.webapps.mediagoblin.withPlugins (p: [p.basicsearch]);
106 configFile = config.secrets.fullPaths."webapps/tools-mediagoblin";
107 };
108 services.filesWatcher.mediagoblin-web = {
109 restart = true;
110 paths = [ mcfg.configFile ];
111 };
112 services.filesWatcher.mediagoblin-celeryd = {
113 restart = true;
114 paths = [ mcfg.configFile ];
115 };
116
117 services.websites.env.tools.modules = [
118 "proxy" "proxy_http"
119 ];
120 users.users.wwwrun.extraGroups = [ "mediagoblin" ];
121 services.websites.env.tools.vhostConfs.mgoblin = {
122 certName = "eldiron";
123 addToCerts = true;
124 hosts = ["mgoblin.immae.eu" ];
125 root = null;
126 extraConfig = [ ''
127 Alias /mgoblin_media ${mcfg.dataDir}/media/public
128 <Directory ${mcfg.dataDir}/media/public>
129 Options -Indexes +FollowSymLinks +MultiViews +Includes
130 Require all granted
131 </Directory>
132
133 Alias /theme_static ${mcfg.dataDir}/theme_static
134 <Directory ${mcfg.dataDir}/theme_static>
135 Options -Indexes +FollowSymLinks +MultiViews +Includes
136 Require all granted
137 </Directory>
138
139 Alias /plugin_static ${mcfg.dataDir}/plugin_static
140 <Directory ${mcfg.dataDir}/plugin_static>
141 Options -Indexes +FollowSymLinks +MultiViews +Includes
142 Require all granted
143 </Directory>
144
145 ProxyPreserveHost on
146 ProxyVia On
147 ProxyRequests Off
148 ProxyPass /mgoblin_media !
149 ProxyPass /theme_static !
150 ProxyPass /plugin_static !
151 ProxyPassMatch ^/.well-known/acme-challenge !
152 ProxyPass / unix://${mcfg.sockets.paster}|http://mgoblin.immae.eu/
153 ProxyPassReverse / unix://${mcfg.sockets.paster}|http://mgoblin.immae.eu/
154 '' ];
155 };
156 };
157 }