various: replace systemd.services.<name>.{script,preStart} with ExecStart{,Pre} (#448763)

This commit is contained in:
Sandro
2025-10-29 12:34:37 +00:00
committed by GitHub
68 changed files with 242 additions and 304 deletions

View File

@@ -298,10 +298,8 @@ in
Type = "oneshot";
Group = "nginx";
UMask = "026";
ExecStart = "${lib.getExe pkgs.bluemap} -c ${configFolder} -gs -r";
};
script = ''
${lib.getExe pkgs.bluemap} -c ${configFolder} -gs -r
'';
};
systemd.timers."render-bluemap-maps" = lib.mkIf cfg.enableRender {

View File

@@ -383,37 +383,44 @@ in
cloudlog-upload-lotw = {
description = "Upload QSOs to LoTW if certs have been provided";
enable = cfg.upload-lotw.enable;
script = "${pkgs.curl}/bin/curl -s ${cfg.baseUrl}/lotw/lotw_upload";
serviceConfig.ExecStart = "${lib.getExe pkgs.curl} -s ${cfg.baseUrl}/lotw/lotw_upload";
serviceConfig.Type = "oneshot";
};
cloudlog-update-lotw-users = {
description = "Update LOTW Users Database";
enable = cfg.update-lotw-users.enable;
script = "${pkgs.curl}/bin/curl -s ${cfg.baseUrl}/lotw/load_users";
serviceConfig.ExecStart = "${lib.getExe pkgs.curl} -s ${cfg.baseUrl}/lotw/load_users";
serviceConfig.Type = "oneshot";
};
cloudlog-update-dok = {
description = "Update DOK File for autocomplete";
enable = cfg.update-dok.enable;
script = "${pkgs.curl}/bin/curl -s ${cfg.baseUrl}/update/update_dok";
serviceConfig.ExecStart = "${lib.getExe pkgs.curl} -s ${cfg.baseUrl}/update/update_dok";
serviceConfig.Type = "oneshot";
};
cloudlog-update-clublog-scp = {
description = "Update Clublog SCP Database File";
enable = cfg.update-clublog-scp.enable;
script = "${pkgs.curl}/bin/curl -s ${cfg.baseUrl}/update/update_clublog_scp";
serviceConfig.ExecStart = "${lib.getExe pkgs.curl} -s ${cfg.baseUrl}/update/update_clublog_scp";
serviceConfig.Type = "oneshot";
};
cloudlog-update-wwff = {
description = "Update WWFF File for autocomplete";
enable = cfg.update-wwff.enable;
script = "${pkgs.curl}/bin/curl -s ${cfg.baseUrl}/update/update_wwff";
serviceConfig.ExecStart = "${lib.getExe pkgs.curl} -s ${cfg.baseUrl}/update/update_wwff";
serviceConfig.Type = "oneshot";
};
cloudlog-upload-qrz = {
description = "Upload QSOs to QRZ Logbook";
enable = cfg.upload-qrz.enable;
script = "${pkgs.curl}/bin/curl -s ${cfg.baseUrl}/qrz/upload";
serviceConfig.ExecStart = "${lib.getExe pkgs.curl} -s ${cfg.baseUrl}/qrz/upload";
serviceConfig.Type = "oneshot";
};
cloudlog-update-sota = {
description = "Update SOTA File for autocomplete";
enable = cfg.update-sota.enable;
script = "${pkgs.curl}/bin/curl -s ${cfg.baseUrl}/update/update_sota";
serviceConfig.ExecStart = "${lib.getExe pkgs.curl} -s ${cfg.baseUrl}/update/update_sota";
serviceConfig.Type = "oneshot";
};
};
timers = {

View File

@@ -133,19 +133,16 @@ in
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
preStart = ''
${optionalString (cfg.insecure != true && cfg.certFile != null && cfg.keyFile != null) ''
install -m 700 -o '${cfg.user}' -g '${cfg.group}' ${cfg.certFile} ${cfg.dataDir}/cert.pem
install -m 700 -o '${cfg.user}' -g '${cfg.group}' ${cfg.keyFile} ${cfg.dataDir}/key.pem
''}
'';
serviceConfig = mkMerge [
{
Type = "simple";
User = cfg.user;
Group = cfg.group;
WorkingDirectory = cfg.stateDir;
ExecStartPre = lib.mkIf (cfg.insecure != true && cfg.certFile != null && cfg.keyFile != null) [
"${lib.getExe' pkgs.coreutils "install"} -m 700 -o '${cfg.user}' -g '${cfg.group}' ${cfg.certFile} ${cfg.dataDir}/cert.pem"
"${lib.getExe' pkgs.coreutils "install"} -m 700 -o '${cfg.user}' -g '${cfg.group}' ${cfg.keyFile} ${cfg.dataDir}/key.pem"
];
ExecStart = ''
${cfg.package}/bin/galene \
${optionalString (cfg.insecure) "-insecure"} \

View File

@@ -236,11 +236,8 @@ in
glitchtip = commonService // {
description = "GlitchTip";
preStart = ''
${lib.getExe pkg} migrate
'';
serviceConfig = commonServiceConfig // {
ExecStartPre = "${lib.getExe pkg} migrate";
ExecStart = ''
${lib.getExe python.pkgs.gunicorn} \
--bind=${cfg.listenAddress}:${toString cfg.port} \

View File

@@ -237,14 +237,13 @@ in
wantedBy = [ "healthchecks.target" ];
after = [ "healthchecks-migration.service" ];
preStart = ''
${pkg}/opt/healthchecks/manage.py collectstatic --no-input
${pkg}/opt/healthchecks/manage.py remove_stale_contenttypes --no-input
''
+ lib.optionalString (cfg.settings.DEBUG != "True") "${pkg}/opt/healthchecks/manage.py compress";
serviceConfig = commonConfig // {
Restart = "always";
ExecStartPre = [
"${pkg}/opt/healthchecks/manage.py collectstatic --no-input"
"${pkg}/opt/healthchecks/manage.py remove_stale_contenttypes --no-input"
]
++ lib.optionals (cfg.settings.DEBUG != "True") [ "${pkg}/opt/healthchecks/manage.py compress" ];
ExecStart = ''
${pkgs.python3Packages.gunicorn}/bin/gunicorn hc.wsgi \
--bind ${cfg.listenAddress}:${toString cfg.port} \

View File

@@ -310,19 +310,6 @@ in
in
{
mediagoblin-celeryd = lib.recursiveUpdate serviceDefaults {
# we cannot change DEFAULT.data_dir inside mediagoblin.ini because of an annoying bug
# https://todo.sr.ht/~mediagoblin/mediagoblin/57
preStart = ''
cp --remove-destination ${
pkgs.writeText "mediagoblin.ini" (
lib.generators.toINI { } (lib.filterAttrsRecursive (n: v: n != "plugins") cfg.settings)
+ "\n"
+ lib.generators.toINI { mkKeyValue = mkSubSectionKeyValue 2; } {
inherit (cfg.settings.mediagoblin) plugins;
}
)
} /var/lib/mediagoblin/mediagoblin.ini
'';
serviceConfig = {
Environment = [
"CELERY_CONFIG_MODULE=mediagoblin.init.celery.from_celery"
@@ -331,6 +318,19 @@ in
"MEDIAGOBLIN_CONFIG=/var/lib/mediagoblin/mediagoblin.ini"
"PASTE_CONFIG=${pasteConfig}"
];
# we cannot change DEFAULT.data_dir inside mediagoblin.ini because of an annoying bug
# https://todo.sr.ht/~mediagoblin/mediagoblin/57
ExecStartPre = ''
${lib.getExe' pkgs.coreutils "cp"} --remove-destination ${
pkgs.writeText "mediagoblin.ini" (
lib.generators.toINI { } (lib.filterAttrsRecursive (n: v: n != "plugins") cfg.settings)
+ "\n"
+ lib.generators.toINI { mkKeyValue = mkSubSectionKeyValue 2; } {
inherit (cfg.settings.mediagoblin) plugins;
}
)
} /var/lib/mediagoblin/mediagoblin.ini
'';
ExecStart = "${lib.getExe' finalPackage "celery"} worker --loglevel=INFO";
};
unitConfig.Description = "MediaGoblin Celery";
@@ -345,16 +345,16 @@ in
"mediagoblin-celeryd.service"
"postgresql.target"
];
preStart = ''
cp --remove-destination ${pasteConfig} /var/lib/mediagoblin/paste.ini
${lib.getExe' finalPackage "gmg"} dbupdate
'';
serviceConfig = {
Environment = [
"CELERY_ALWAYS_EAGER=false"
"GI_TYPELIB_PATH=${GI_TYPELIB_PATH}"
"GST_PLUGIN_PATH=${GST_PLUGIN_PATH}"
];
ExecStartPre = [
"${lib.getExe' pkgs.coreutils "cp"} --remove-destination ${pasteConfig} /var/lib/mediagoblin/paste.ini"
"${lib.getExe' finalPackage "gmg"} dbupdate"
];
ExecStart = "${lib.getExe' finalPackage "paster"} serve /var/lib/mediagoblin/paste.ini";
};
unitConfig.Description = "Mediagoblin";

View File

@@ -18,14 +18,6 @@ let
cfg = config.services.miniflux;
boolToInt = b: if b then 1 else 0;
pgbin = "${config.services.postgresql.package}/bin";
# The hstore extension is no longer needed as of v2.2.14
# and would prevent Miniflux from starting.
preStart = pkgs.writeScript "miniflux-pre-start" ''
#!${pkgs.runtimeShell}
${pgbin}/psql "miniflux" -c "DROP EXTENSION IF EXISTS hstore"
'';
in
{
@@ -141,7 +133,9 @@ in
serviceConfig = {
Type = "oneshot";
User = config.services.postgresql.superUser;
ExecStart = preStart;
# The hstore extension is no longer needed as of v2.2.14
# and would prevent Miniflux from starting.
ExecStart = ''${config.services.postgresql.package}/bin/psql "miniflux" -c "DROP EXTENSION IF EXISTS hstore"'';
};
};

View File

@@ -326,19 +326,19 @@ in
environment = {
MISSKEY_CONFIG_YML = "/run/misskey/default.yml";
};
preStart = ''
install -m 700 ${settingsFormat.generate "misskey-config.yml" cfg.settings} /run/misskey/default.yml
''
+ (lib.optionalString (cfg.database.passwordFile != null) ''
${pkgs.replace-secret}/bin/replace-secret '@DATABASE_PASSWORD@' "${cfg.database.passwordFile}" /run/misskey/default.yml
'')
+ (lib.optionalString (cfg.redis.passwordFile != null) ''
${pkgs.replace-secret}/bin/replace-secret '@REDIS_PASSWORD@' "${cfg.redis.passwordFile}" /run/misskey/default.yml
'')
+ (lib.optionalString (cfg.meilisearch.keyFile != null) ''
${pkgs.replace-secret}/bin/replace-secret '@MEILISEARCH_KEY@' "${cfg.meilisearch.keyFile}" /run/misskey/default.yml
'');
serviceConfig = {
ExecStartPre = [
"${lib.getExe' pkgs.coreutils "install"} -m 700 ${settingsFormat.generate "misskey-config.yml" cfg.settings} /run/misskey/default.yml"
]
++ (lib.optionals (cfg.database.passwordFile != null) [
"${lib.getExe pkgs.replace-secret} '@DATABASE_PASSWORD@' '${cfg.database.passwordFile}' /run/misskey/default.yml"
])
++ (lib.optionals (cfg.redis.passwordFile != null) [
"${lib.getExe pkgs.replace-secret} '@REDIS_PASSWORD@' '${cfg.redis.passwordFile}' /run/misskey/default.yml"
])
++ (lib.optionals (cfg.meilisearch.keyFile != null) [
"${lib.getExe pkgs.replace-secret} '@MEILISEARCH_KEY@' '${cfg.meilisearch.keyFile}' /run/misskey/default.yml"
]);
ExecStart = "${cfg.package}/bin/misskey migrateandstart";
RuntimeDirectory = "misskey";
RuntimeDirectoryMode = "700";

View File

@@ -142,9 +142,8 @@ in
fi
'';
script = "${cfg.package}/bin/nexus run";
serviceConfig = {
ExecStart = "${cfg.package}/bin/nexus run";
User = cfg.user;
Group = cfg.group;
PrivateTmp = true;

View File

@@ -200,6 +200,7 @@ in
requires = [ "postgresql.target" ];
wantedBy = [ "multi-user.target" ];
serviceConfig = {
ExecStart = "${lib.getExe cfg.phpPackage} ${lib.getExe' cfg.package "console"} doctrine:migrations:migrate --no-interaction";
Type = "oneshot";
RemainAfterExit = true;
User = "part-db";
@@ -207,10 +208,6 @@ in
restartTriggers = [
cfg.package
];
script = ''
set -euo pipefail
${lib.getExe cfg.phpPackage} ${lib.getExe' cfg.package "console"} doctrine:migrations:migrate --no-interaction
'';
};
phpfpm-part-db = {

View File

@@ -307,11 +307,8 @@ in
]
++ lib.optionals (cfg.environmentFile != null) [ "peering-manager-config.service" ];
preStart = ''
${pkg}/bin/peering-manager remove_stale_contenttypes --no-input
'';
serviceConfig = {
ExecStartPre = "${pkg}/bin/peering-manager remove_stale_contenttypes --no-input";
ExecStart = ''
${pkg.python.pkgs.gunicorn}/bin/gunicorn peering_manager.wsgi \
--bind ${cfg.listenAddress}:${toString cfg.port} \

View File

@@ -95,7 +95,6 @@ in
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
preStart = lib.mkIf (!lib.hasPrefix "/var/lib/" cfg.spaceDir) "mkdir -p '${cfg.spaceDir}'";
serviceConfig = {
Type = "simple";
User = "${cfg.user}";
@@ -104,6 +103,9 @@ in
StateDirectory = lib.mkIf (lib.hasPrefix "/var/lib/" cfg.spaceDir) (
lib.last (lib.splitString "/" cfg.spaceDir)
);
ExecStartPre = lib.mkIf (
!lib.hasPrefix "/var/lib/" cfg.spaceDir
) "${lib.getExe' pkgs.coreutils "mkdir"} -p '${cfg.spaceDir}'";
ExecStart =
"${lib.getExe cfg.package} --port ${toString cfg.listenPort} --hostname '${cfg.listenAddress}' '${cfg.spaceDir}' "
+ lib.concatStringsSep " " cfg.extraArgs;

View File

@@ -143,10 +143,6 @@ in
++ optional (cfg.database.dialect == "postgres") "postgresql.target";
wantedBy = [ "multi-user.target" ];
script = ''
exec ${getExe cfg.package} -config ${settingsFile}
'';
serviceConfig = {
Environment = mkMerge [
(mkIf (cfg.passwordSalt != null) "WAKAPI_PASSWORD_SALT=${cfg.passwordSalt}")
@@ -157,6 +153,8 @@ in
(lib.optional (cfg.passwordSaltFile != null) cfg.passwordSaltFile)
++ (lib.optional (cfg.smtpPasswordFile != null) cfg.smtpPasswordFile);
ExecStart = "${getExe cfg.package} -config ${settingsFile}";
User = config.users.users.wakapi.name;
Group = config.users.users.wakapi.group;