aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2019-05-10 19:13:59 +0200
committerIsmaël Bouya <ismael.bouya@normalesup.org>2019-05-10 19:14:36 +0200
commit658822fb4a42be89b2ea47e111532513c4556d87 (patch)
tree99fa51122ad9a61db7c7d7d21c16f4c57ec3f0b5
parent613aea5685ad4c698386c374474d8853bb736503 (diff)
downloadNix-658822fb4a42be89b2ea47e111532513c4556d87.tar.gz
Nix-658822fb4a42be89b2ea47e111532513c4556d87.tar.zst
Nix-658822fb4a42be89b2ea47e111532513c4556d87.zip
Add exported values in mediagoblin module
-rw-r--r--modules/webapps/mediagoblin.nix51
-rw-r--r--nixops/modules/websites/tools/mediagoblin.nix4
2 files changed, 42 insertions, 13 deletions
diff --git a/modules/webapps/mediagoblin.nix b/modules/webapps/mediagoblin.nix
index 6808c82..0232aab 100644
--- a/modules/webapps/mediagoblin.nix
+++ b/modules/webapps/mediagoblin.nix
@@ -6,7 +6,6 @@ let
6 uid = config.ids.uids.mediagoblin; 6 uid = config.ids.uids.mediagoblin;
7 gid = config.ids.gids.mediagoblin; 7 gid = config.ids.gids.mediagoblin;
8 8
9 fullPackage = cfg.package.withPlugins cfg.plugins;
10 paste_local = pkgs.writeText "paste_local.ini" '' 9 paste_local = pkgs.writeText "paste_local.ini" ''
11 [DEFAULT] 10 [DEFAULT]
12 debug = false 11 debug = false
@@ -16,8 +15,8 @@ let
16 15
17 [app:mediagoblin] 16 [app:mediagoblin]
18 use = egg:mediagoblin#app 17 use = egg:mediagoblin#app
19 config = ${cfg.configFile} ${fullPackage}/mediagoblin.ini 18 config = ${cfg.configFile} ${cfg.workdir}/mediagoblin.ini
20 /mgoblin_static = ${fullPackage}/mediagoblin/static 19 /mgoblin_static = ${cfg.workdir}/mediagoblin/static
21 20
22 [loggers] 21 [loggers]
23 keys = root 22 keys = root
@@ -47,7 +46,7 @@ let
47 46
48 [server:main] 47 [server:main]
49 use = egg:waitress#main 48 use = egg:waitress#main
50 unix_socket = ${cfg.socketsDir}/mediagoblin.sock 49 unix_socket = ${cfg.sockets.paster}
51 unix_socket_perms = 777 50 unix_socket_perms = 777
52 url_scheme = https 51 url_scheme = https
53 ''; 52 '';
@@ -99,6 +98,36 @@ in
99 Mediagoblin plugins to use. 98 Mediagoblin plugins to use.
100 ''; 99 '';
101 }; 100 };
101 # Output variables
102 workdir = lib.mkOption {
103 type = lib.types.package;
104 default = cfg.package.withPlugins cfg.plugins;
105 description = ''
106 Adjusted Mediagoblin package with plugins
107 '';
108 readOnly = true;
109 };
110 sockets = lib.mkOption {
111 type = lib.types.attrsOf lib.types.path;
112 default = {
113 paster = "${cfg.socketsDir}/mediagoblin.sock";
114 };
115 readOnly = true;
116 description = ''
117 Mediagoblin sockets
118 '';
119 };
120 pids = lib.mkOption {
121 type = lib.types.attrsOf lib.types.path;
122 default = {
123 paster = "${cfg.socketsDir}/mediagoblin.pid";
124 celery = "${cfg.socketsDir}/mediagoblin-celeryd.pid";
125 };
126 readOnly = true;
127 description = ''
128 Mediagoblin pid files
129 '';
130 };
102 }; 131 };
103 132
104 config = lib.mkIf cfg.enable { 133 config = lib.mkIf cfg.enable {
@@ -126,11 +155,11 @@ in
126 script = '' 155 script = ''
127 exec ./bin/paster serve \ 156 exec ./bin/paster serve \
128 ${paste_local} \ 157 ${paste_local} \
129 --pid-file=${cfg.socketsDir}/mediagoblin.pid 158 --pid-file=${cfg.pids.paster}
130 ''; 159 '';
131 preStop = '' 160 preStop = ''
132 exec ./bin/paster serve \ 161 exec ./bin/paster serve \
133 --pid-file=${cfg.socketsDir}/mediagoblin.pid \ 162 --pid-file=${cfg.pids.paster} \
134 ${paste_local} stop 163 ${paste_local} stop
135 ''; 164 '';
136 preStart = '' 165 preStart = ''
@@ -143,8 +172,8 @@ in
143 Restart = "always"; 172 Restart = "always";
144 TimeoutSec = 15; 173 TimeoutSec = 15;
145 Type = "simple"; 174 Type = "simple";
146 WorkingDirectory = fullPackage; 175 WorkingDirectory = cfg.workdir;
147 PIDFile = "${cfg.socketsDir}/mediagoblin.pid"; 176 PIDFile = cfg.pids.paster;
148 }; 177 };
149 178
150 unitConfig.RequiresMountsFor = cfg.dataDir; 179 unitConfig.RequiresMountsFor = cfg.dataDir;
@@ -170,8 +199,8 @@ in
170 Restart = "always"; 199 Restart = "always";
171 TimeoutSec = 60; 200 TimeoutSec = 60;
172 Type = "simple"; 201 Type = "simple";
173 WorkingDirectory = fullPackage; 202 WorkingDirectory = cfg.workdir;
174 PIDFile = "${cfg.socketsDir}/mediagoblin-celeryd.pid"; 203 PIDFile = cfg.pids.celery;
175 }; 204 };
176 205
177 unitConfig.RequiresMountsFor = cfg.dataDir; 206 unitConfig.RequiresMountsFor = cfg.dataDir;
@@ -184,7 +213,7 @@ in
184 install -m 0755 -o ${cfg.user} -g ${cfg.group} -d ${cfg.dataDir} 213 install -m 0755 -o ${cfg.user} -g ${cfg.group} -d ${cfg.dataDir}
185 if [ -d ${cfg.dataDir}/plugin_static/ ]; then 214 if [ -d ${cfg.dataDir}/plugin_static/ ]; then
186 rm ${cfg.dataDir}/plugin_static/coreplugin_basic_auth 215 rm ${cfg.dataDir}/plugin_static/coreplugin_basic_auth
187 ln -sf ${fullPackage}/mediagoblin/plugins/basic_auth/static ${cfg.dataDir}/plugin_static/coreplugin_basic_auth 216 ln -sf ${cfg.workdir}/mediagoblin/plugins/basic_auth/static ${cfg.dataDir}/plugin_static/coreplugin_basic_auth
188 fi 217 fi
189 ''; 218 '';
190 }; 219 };
diff --git a/nixops/modules/websites/tools/mediagoblin.nix b/nixops/modules/websites/tools/mediagoblin.nix
index bf45e8e..cdc45ae 100644
--- a/nixops/modules/websites/tools/mediagoblin.nix
+++ b/nixops/modules/websites/tools/mediagoblin.nix
@@ -114,8 +114,8 @@ in {
114 ProxyPass /theme_static ! 114 ProxyPass /theme_static !
115 ProxyPass /plugin_static ! 115 ProxyPass /plugin_static !
116 ProxyPassMatch ^/.well-known/acme-challenge ! 116 ProxyPassMatch ^/.well-known/acme-challenge !
117 ProxyPass / unix://${mcfg.socketsDir}/mediagoblin.sock|http://mgoblin.immae.eu/ 117 ProxyPass / unix://${mcfg.sockets.paster}|http://mgoblin.immae.eu/
118 ProxyPassReverse / unix://${mcfg.socketsDir}/mediagoblin.sock|http://mgoblin.immae.eu/ 118 ProxyPassReverse / unix://${mcfg.sockets.paster}|http://mgoblin.immae.eu/
119 '' ]; 119 '' ];
120 }; 120 };
121 }; 121 };