diff options
Diffstat (limited to 'modules/webapps')
-rw-r--r-- | modules/webapps/mediagoblin.nix | 51 |
1 files changed, 40 insertions, 11 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 | }; |