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