]> git.immae.eu Git - perso/Immae/Config/Nix.git/blob - modules/private/websites/tools/mgoblin/default.nix
Remove duply-backup
[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 secrets.keys."webapps/tools-mediagoblin" = {
13 user = "mediagoblin";
14 group = "mediagoblin";
15 permissions = "0400";
16 text =
17 let
18 psql_url = with env.postgresql; "postgresql://${user}:${password}@:${port}/${database}?host=${socket}";
19 redis_url = with env.redis; "redis+socket://${socket}?virtual_host=${db}";
20 in
21 ''
22 [DEFAULT]
23 data_basedir = "${mcfg.dataDir}"
24
25 [mediagoblin]
26 direct_remote_path = /mgoblin_static/
27 email_sender_address = "mediagoblin@tools.immae.eu"
28
29 #sql_engine = sqlite:///%(data_basedir)s/mediagoblin.db
30 sql_engine = ${psql_url}
31
32 email_debug_mode = false
33 allow_registration = false
34 allow_reporting = true
35
36 theme = airymodified
37
38 user_privilege_scheme = "uploader,commenter,reporter"
39
40 # We need to redefine them here since we override data_basedir
41 # cf /usr/share/webapps/mediagoblin/mediagoblin/config_spec.ini
42 workbench_path = %(data_basedir)s/media/workbench
43 crypto_path = %(data_basedir)s/crypto
44 theme_install_dir = %(data_basedir)s/themes/
45 theme_linked_assets_dir = %(data_basedir)s/theme_static/
46 plugin_linked_assets_dir = %(data_basedir)s/plugin_static/
47
48 [storage:queuestore]
49 base_dir = %(data_basedir)s/media/queue
50
51 [storage:publicstore]
52 base_dir = %(data_basedir)s/media/public
53 base_url = /mgoblin_media/
54
55 [celery]
56 CELERY_RESULT_DBURI = ${redis_url}
57 BROKER_URL = ${redis_url}
58 CELERYD_CONCURRENCY = 1
59
60 [plugins]
61 [[mediagoblin.plugins.geolocation]]
62 [[mediagoblin.plugins.ldap]]
63 [[[immae.eu]]]
64 LDAP_SERVER_URI = 'ldaps://${env.ldap.host}:636'
65 LDAP_SEARCH_BASE = '${env.ldap.base}'
66 LDAP_BIND_DN = '${env.ldap.dn}'
67 LDAP_BIND_PW = '${env.ldap.password}'
68 LDAP_SEARCH_FILTER = '${env.ldap.filter}'
69 EMAIL_SEARCH_FIELD = 'mail'
70 [[mediagoblin.plugins.basicsearch]]
71 [[mediagoblin.plugins.piwigo]]
72 [[mediagoblin.plugins.processing_info]]
73 [[mediagoblin.media_types.image]]
74 [[mediagoblin.media_types.video]]
75 '';
76 };
77
78 users.users.mediagoblin.extraGroups = [ "keys" ];
79
80 services.mediagoblin = {
81 enable = true;
82 package = pkgs.webapps.mediagoblin.withPlugins (p: [p.basicsearch]);
83 configFile = config.secrets.fullPaths."webapps/tools-mediagoblin";
84 };
85 services.filesWatcher.mediagoblin-web = {
86 restart = true;
87 paths = [ mcfg.configFile ];
88 };
89 services.filesWatcher.mediagoblin-celeryd = {
90 restart = true;
91 paths = [ mcfg.configFile ];
92 };
93
94 services.websites.env.tools.modules = [
95 "proxy" "proxy_http"
96 ];
97 users.users.wwwrun.extraGroups = [ "mediagoblin" ];
98 services.websites.env.tools.vhostConfs.mgoblin = {
99 certName = "eldiron";
100 addToCerts = true;
101 hosts = ["mgoblin.immae.eu" ];
102 root = null;
103 extraConfig = [ ''
104 Alias /mgoblin_media ${mcfg.dataDir}/media/public
105 <Directory ${mcfg.dataDir}/media/public>
106 Options -Indexes +FollowSymLinks +MultiViews +Includes
107 Require all granted
108 </Directory>
109
110 Alias /theme_static ${mcfg.dataDir}/theme_static
111 <Directory ${mcfg.dataDir}/theme_static>
112 Options -Indexes +FollowSymLinks +MultiViews +Includes
113 Require all granted
114 </Directory>
115
116 Alias /plugin_static ${mcfg.dataDir}/plugin_static
117 <Directory ${mcfg.dataDir}/plugin_static>
118 Options -Indexes +FollowSymLinks +MultiViews +Includes
119 Require all granted
120 </Directory>
121
122 ProxyPreserveHost on
123 ProxyVia On
124 ProxyRequests Off
125 ProxyPass /mgoblin_media !
126 ProxyPass /theme_static !
127 ProxyPass /plugin_static !
128 ProxyPassMatch ^/.well-known/acme-challenge !
129 ProxyPass / unix://${mcfg.sockets.paster}|http://mgoblin.immae.eu/
130 ProxyPassReverse / unix://${mcfg.sockets.paster}|http://mgoblin.immae.eu/
131 '' ];
132 };
133 };
134 }