]> git.immae.eu Git - perso/Immae/Config/Nix.git/blame - modules/private/websites/tools/mgoblin/default.nix
Remove duply-backup
[perso/Immae/Config/Nix.git] / modules / private / websites / tools / mgoblin / default.nix
CommitLineData
ab8f306d 1{ lib, pkgs, config, ... }:
56eba416 2let
ab8f306d 3 env = config.myEnv.tools.mediagoblin;
4288c2f2 4 cfg = config.myServices.websites.tools.mediagoblin;
996a68c2 5 mcfg = config.services.mediagoblin;
56eba416 6in {
4288c2f2 7 options.myServices.websites.tools.mediagoblin = {
56eba416
IB
8 enable = lib.mkEnableOption "enable mediagoblin's website";
9 };
10
11 config = lib.mkIf cfg.enable {
4c4652aa 12 secrets.keys."webapps/tools-mediagoblin" = {
ddd3f845
IB
13 user = "mediagoblin";
14 group = "mediagoblin";
15 permissions = "0400";
ab8f306d
IB
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 ''
ddd3f845 22 [DEFAULT]
996a68c2 23 data_basedir = "${mcfg.dataDir}"
ddd3f845
IB
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
ab8f306d 30 sql_engine = ${psql_url}
ddd3f845
IB
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]
ab8f306d
IB
56 CELERY_RESULT_DBURI = ${redis_url}
57 BROKER_URL = ${redis_url}
ddd3f845
IB
58 CELERYD_CONCURRENCY = 1
59
60 [plugins]
61 [[mediagoblin.plugins.geolocation]]
62 [[mediagoblin.plugins.ldap]]
63 [[[immae.eu]]]
ab8f306d
IB
64 LDAP_SERVER_URI = 'ldaps://${env.ldap.host}:636'
65 LDAP_SEARCH_BASE = '${env.ldap.base}'
66 LDAP_BIND_DN = '${env.ldap.dn}'
ddd3f845 67 LDAP_BIND_PW = '${env.ldap.password}'
ab8f306d 68 LDAP_SEARCH_FILTER = '${env.ldap.filter}'
ddd3f845
IB
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 '';
4c4652aa 76 };
ddd3f845 77
996a68c2 78 users.users.mediagoblin.extraGroups = [ "keys" ];
56eba416 79
996a68c2
IB
80 services.mediagoblin = {
81 enable = true;
34c7b88e 82 package = pkgs.webapps.mediagoblin.withPlugins (p: [p.basicsearch]);
da30ae4f 83 configFile = config.secrets.fullPaths."webapps/tools-mediagoblin";
56eba416 84 };
17f6eae9
IB
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 };
56eba416 93
29f8cb85 94 services.websites.env.tools.modules = [
a952acc4 95 "proxy" "proxy_http"
56eba416
IB
96 ];
97 users.users.wwwrun.extraGroups = [ "mediagoblin" ];
29f8cb85 98 services.websites.env.tools.vhostConfs.mgoblin = {
56eba416 99 certName = "eldiron";
7df420c2 100 addToCerts = true;
56eba416
IB
101 hosts = ["mgoblin.immae.eu" ];
102 root = null;
103 extraConfig = [ ''
996a68c2
IB
104 Alias /mgoblin_media ${mcfg.dataDir}/media/public
105 <Directory ${mcfg.dataDir}/media/public>
56eba416
IB
106 Options -Indexes +FollowSymLinks +MultiViews +Includes
107 Require all granted
108 </Directory>
109
996a68c2
IB
110 Alias /theme_static ${mcfg.dataDir}/theme_static
111 <Directory ${mcfg.dataDir}/theme_static>
56eba416
IB
112 Options -Indexes +FollowSymLinks +MultiViews +Includes
113 Require all granted
114 </Directory>
115
996a68c2
IB
116 Alias /plugin_static ${mcfg.dataDir}/plugin_static
117 <Directory ${mcfg.dataDir}/plugin_static>
56eba416
IB
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 !
658822fb
IB
129 ProxyPass / unix://${mcfg.sockets.paster}|http://mgoblin.immae.eu/
130 ProxyPassReverse / unix://${mcfg.sockets.paster}|http://mgoblin.immae.eu/
56eba416
IB
131 '' ];
132 };
133 };
134}