From 658822fb4a42be89b2ea47e111532513c4556d87 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Isma=C3=ABl=20Bouya?= Date: Fri, 10 May 2019 19:13:59 +0200 Subject: [PATCH] Add exported values in mediagoblin module --- modules/webapps/mediagoblin.nix | 51 +++++++++++++++---- nixops/modules/websites/tools/mediagoblin.nix | 4 +- 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 uid = config.ids.uids.mediagoblin; gid = config.ids.gids.mediagoblin; - fullPackage = cfg.package.withPlugins cfg.plugins; paste_local = pkgs.writeText "paste_local.ini" '' [DEFAULT] debug = false @@ -16,8 +15,8 @@ let [app:mediagoblin] use = egg:mediagoblin#app - config = ${cfg.configFile} ${fullPackage}/mediagoblin.ini - /mgoblin_static = ${fullPackage}/mediagoblin/static + config = ${cfg.configFile} ${cfg.workdir}/mediagoblin.ini + /mgoblin_static = ${cfg.workdir}/mediagoblin/static [loggers] keys = root @@ -47,7 +46,7 @@ let [server:main] use = egg:waitress#main - unix_socket = ${cfg.socketsDir}/mediagoblin.sock + unix_socket = ${cfg.sockets.paster} unix_socket_perms = 777 url_scheme = https ''; @@ -99,6 +98,36 @@ in Mediagoblin plugins to use. ''; }; + # Output variables + workdir = lib.mkOption { + type = lib.types.package; + default = cfg.package.withPlugins cfg.plugins; + description = '' + Adjusted Mediagoblin package with plugins + ''; + readOnly = true; + }; + sockets = lib.mkOption { + type = lib.types.attrsOf lib.types.path; + default = { + paster = "${cfg.socketsDir}/mediagoblin.sock"; + }; + readOnly = true; + description = '' + Mediagoblin sockets + ''; + }; + pids = lib.mkOption { + type = lib.types.attrsOf lib.types.path; + default = { + paster = "${cfg.socketsDir}/mediagoblin.pid"; + celery = "${cfg.socketsDir}/mediagoblin-celeryd.pid"; + }; + readOnly = true; + description = '' + Mediagoblin pid files + ''; + }; }; config = lib.mkIf cfg.enable { @@ -126,11 +155,11 @@ in script = '' exec ./bin/paster serve \ ${paste_local} \ - --pid-file=${cfg.socketsDir}/mediagoblin.pid + --pid-file=${cfg.pids.paster} ''; preStop = '' exec ./bin/paster serve \ - --pid-file=${cfg.socketsDir}/mediagoblin.pid \ + --pid-file=${cfg.pids.paster} \ ${paste_local} stop ''; preStart = '' @@ -143,8 +172,8 @@ in Restart = "always"; TimeoutSec = 15; Type = "simple"; - WorkingDirectory = fullPackage; - PIDFile = "${cfg.socketsDir}/mediagoblin.pid"; + WorkingDirectory = cfg.workdir; + PIDFile = cfg.pids.paster; }; unitConfig.RequiresMountsFor = cfg.dataDir; @@ -170,8 +199,8 @@ in Restart = "always"; TimeoutSec = 60; Type = "simple"; - WorkingDirectory = fullPackage; - PIDFile = "${cfg.socketsDir}/mediagoblin-celeryd.pid"; + WorkingDirectory = cfg.workdir; + PIDFile = cfg.pids.celery; }; unitConfig.RequiresMountsFor = cfg.dataDir; @@ -184,7 +213,7 @@ in install -m 0755 -o ${cfg.user} -g ${cfg.group} -d ${cfg.dataDir} if [ -d ${cfg.dataDir}/plugin_static/ ]; then rm ${cfg.dataDir}/plugin_static/coreplugin_basic_auth - ln -sf ${fullPackage}/mediagoblin/plugins/basic_auth/static ${cfg.dataDir}/plugin_static/coreplugin_basic_auth + ln -sf ${cfg.workdir}/mediagoblin/plugins/basic_auth/static ${cfg.dataDir}/plugin_static/coreplugin_basic_auth fi ''; }; 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 { ProxyPass /theme_static ! ProxyPass /plugin_static ! ProxyPassMatch ^/.well-known/acme-challenge ! - ProxyPass / unix://${mcfg.socketsDir}/mediagoblin.sock|http://mgoblin.immae.eu/ - ProxyPassReverse / unix://${mcfg.socketsDir}/mediagoblin.sock|http://mgoblin.immae.eu/ + ProxyPass / unix://${mcfg.sockets.paster}|http://mgoblin.immae.eu/ + ProxyPassReverse / unix://${mcfg.sockets.paster}|http://mgoblin.immae.eu/ '' ]; }; }; -- 2.41.0