nixos/pretalx: remove elevation from the pretalx-manage wrapper

This reduces execution of pretalx-manage to root, so there is no
dependency on sudo, a setuid root binary, any more.
This commit is contained in:
Martin Weinelt
2026-06-14 13:06:41 +02:00
parent 091abce836
commit aa8c9f5d9a
+23 -12
View File
@@ -27,6 +27,28 @@ let
cfg.settings.database.backend == "postgresql"
) finalPackage.optional-dependencies.postgres;
};
pretalxManageWrapper = pkgs.writeShellApplication {
name = "pretalx-manage";
runtimeInputs = with pkgs; [
util-linux
];
text = ''
cd ${cfg.settings.filesystem.data}
set -a
${lib.concatMapStringsSep "\n" (file: ''
. ${lib.escapeShellArg file}
'') cfg.environmentFiles}
set +a
export PRETALX_CONFIG_FILE=${configFile}
exec runuser ${
lib.cli.toCommandLineShellGNU { } {
inherit (cfg) user;
preserve-environment = true;
}
} -- ${lib.getExe' pythonEnv "pretalx-manage"} "$@"
'';
};
in
{
@@ -325,18 +347,7 @@ in
# https://docs.pretalx.org/administrator/installation/
environment.systemPackages = [
(pkgs.writeScriptBin "pretalx-manage" ''
cd ${cfg.settings.filesystem.data}
sudo=exec
if [[ "$USER" != ${cfg.user} ]]; then
sudo='exec /run/wrappers/bin/sudo -u ${cfg.user} --preserve-env=PRETALX_CONFIG_FILE'
fi
set -a
${lib.concatMapStringsSep "\n" (file: ". ${lib.escapeShellArg file}") cfg.environmentFiles}
set +a
export PRETALX_CONFIG_FILE=${configFile}
$sudo ${lib.getExe' pythonEnv "pretalx-manage"} "$@"
'')
pretalxManageWrapper
];
services.logrotate.settings.pretalx = {