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
[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
[server:main]
use = egg:waitress#main
- unix_socket = ${cfg.socketsDir}/mediagoblin.sock
+ unix_socket = ${cfg.sockets.paster}
unix_socket_perms = 777
url_scheme = https
'';
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 {
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 = ''
Restart = "always";
TimeoutSec = 15;
Type = "simple";
- WorkingDirectory = fullPackage;
- PIDFile = "${cfg.socketsDir}/mediagoblin.pid";
+ WorkingDirectory = cfg.workdir;
+ PIDFile = cfg.pids.paster;
};
unitConfig.RequiresMountsFor = cfg.dataDir;
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;
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
'';
};