nixos/pretalx: run pretalx-manage migrate on plugin changes and upgrades

Some plugins like https://github.com/pretalx/pretalx-media-ccc-de
require database migrations to properly work.
This commit is contained in:
Sandro Jäckel
2025-10-09 00:47:09 +02:00
parent aaae239f21
commit ad9e817cc2

View File

@@ -439,16 +439,23 @@ in
"mysql.service"
];
wantedBy = [ "multi-user.target" ];
preStart = ''
versionFile="${cfg.settings.filesystem.data}/.version"
version=$(cat "$versionFile" 2>/dev/null || echo 0)
preStart =
let
versionString = lib.concatStringsSep "\n" (
[ "pretalx-${cfg.package.version}" ]
++ map (plugin: "${plugin.pname}-${plugin.version}") cfg.plugins
);
in
''
versionFile="${cfg.settings.filesystem.data}/.version"
version="$(cat "$versionFile" 2>/dev/null || echo 0)"
if [[ $version != ${cfg.package.version} ]]; then
${lib.getExe' pythonEnv "pretalx-manage"} migrate
if [[ "$version" != "${versionString}" ]]; then
${lib.getExe' pythonEnv "pretalx-manage"} migrate
echo "${cfg.package.version}" > "$versionFile"
fi
'';
echo "${versionString}" > "$versionFile"
fi
'';
serviceConfig = {
ExecStart = "${lib.getExe' pythonEnv "gunicorn"} --bind unix:/run/pretalx/pretalx.sock ${cfg.gunicorn.extraArgs} pretalx.wsgi";
RuntimeDirectory = "pretalx";