From e6e82b8a4aae7cc6f81e5af6260d2cd5a2e002e6 Mon Sep 17 00:00:00 2001 From: oqyude Date: Wed, 14 Oct 2026 17:46:50 +0300 Subject: [PATCH] fix(gitea-runner): drop serviceConfig overrides that shadow upstream unit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ServiceConfig-level leaf assignments (or a single lib.mkMerge block) into systemd.services.gitea-runner-ci-sapphira.serviceConfig were silently replacing Nixpkgs's services.gitea-actions-runner module output: the generated unit came out without ExecStart / ExecStartPre / LoadCredential / User / Restart / RestartSec / StateDirectory, so systemd refused to start the service ('Service has no ExecStart=... Refusing'). [Unit]-side overrides DO merge, so the storage guard (ConditionPathIsMountPoint on xlib.dirs.server-home) and the local-fs.target After= are kept. Cgroup caps (CPUQuota, MemoryMax, OOM knobs) are deferred — a follow-up should add them via a systemd drop-in (/etc/systemd/system/gitea-runner-ci\x2dsapphira.service.d/override.conf) so the upstream ExecStart path stays intact. Verified at 2026-10-14 17:36 MSK: register + declare succeed on sapphira after this commit's deploy + a sops format fix (next commit). --- modules/server/gitea-runner.nix | 52 +++++++++----------------- secrets/gitea-runner-registration.env | 13 +++++++ secrets/gitea-runner-registration.yaml | 28 -------------- 3 files changed, 30 insertions(+), 63 deletions(-) create mode 100644 secrets/gitea-runner-registration.env delete mode 100644 secrets/gitea-runner-registration.yaml diff --git a/modules/server/gitea-runner.nix b/modules/server/gitea-runner.nix index e8590b7..ab676df 100644 --- a/modules/server/gitea-runner.nix +++ b/modules/server/gitea-runner.nix @@ -7,32 +7,6 @@ }: let name = "ci-sapphira"; - serviceName = "gitea-runner-${name}"; - - # Caps for a background-slow runner on sapphira. Pattern after - # - home/modules/opencode.nix:410 (RAM/OOM knobs on opencode-web) - # - modules/server/systemd.nix:24 (CPU/IO knobs on rsync-archivesta) - # The runner is meant to be the FIRST thing the OOM killer picks if - # something bigger (immich-ML, onlyoffice, syncthing indexer) needs RAM. - runnerServiceConfig = lib.mkMerge [ - (xlib.helpers.mkStorageGuard xlib) - { - # Static user (declared below) instead of ephemeral DynamicUser, so - # the daemon has a stable UID that can own the sops-decrypted token. - DynamicUser = lib.mkForce false; - Group = "gitea-runner"; - - CPUQuota = "15%"; # ~0.3 core — never starve nix-daemon - MemoryHigh = "384M"; # soft backpressure on $HOME/cache - MemoryMax = "512M"; # hard cap, ~10× smaller than opencode - Nice = 19; # lowest priority - IOWeight = 10; - IOSchedulingClass = "idle"; - IOSchedulingPriority = 7; - OOMScoreAdjust = 500; # killed FIRST if host OOMs - OOMPolicy = "continue"; # never restart-loop on cgroup OOM - } - ]; in { # ----- Static user for the runner ---------------------------------------- @@ -118,17 +92,25 @@ in }; # ----- Service unit overrides ------------------------------------------- - # The upstream NixOS module already sets DynamicUser=true, LoadCredential, - # ExecStartPre (re-register on token change), ExecStart, etc. We override - # with mkMerge so those defaults survive and our caps + storage guard - # are added. + # Upstream `services.gitea-actions-runner` produces a full + # systemd.services.gitea-runner-ci-sapphira attrset (ExecStart, + # ExecStartPre registration, LoadCredential, User, Restart, etc.). + # Leaf-level overrides like `systemd.services.X.serviceConfig.Y = Z` + # were tried (and `lib.mkMerge` of full sub-attrset); both silently + # replaced the upstream submodule instead of merging, so the unit + # came out without ExecStart. Cgroup caps + storage guard are now + # applied through (a) the [Unit] side which actually merges, and + # (b) deferred — see follow-up todo for the systemd drop-in that + # reintroduces CPUQuota / MemoryMax / DynamicUser=false. # # No `RequiresMountsFor` (would defeat the storage guard) — see inline - # comment in lib/xlib/helpers.nix:180-189. `After= local-fs.target` - # instead so fstab mounts are up before the unit's Condition check. - systemd.services."${serviceName}" = { - serviceConfig = runnerServiceConfig; - unitConfig.After = [ + # comment in lib/xlib/helpers.nix:180-189. `ConditionPathIsMountPoint` + # lives in [Unit], so the guard only fires correctly here, not via + # mkStorageGuard which historically writes it to serviceConfig. + systemd.services.gitea-runner-ci-sapphira.unitConfig = { + ConditionPathIsMountPoint = + (xlib.helpers.mkStorageGuard xlib).ConditionPathIsMountPoint; + After = [ "local-fs.target" "systemd-tmpfiles-setup.service" ]; diff --git a/secrets/gitea-runner-registration.env b/secrets/gitea-runner-registration.env new file mode 100644 index 0000000..87694fc --- /dev/null +++ b/secrets/gitea-runner-registration.env @@ -0,0 +1,13 @@ +#ENC[AES256_GCM,data:jTxFOObKsO+W1LoWHFo4R/aBAov2XgaYEuiH9bsy5Aj4q9FJ3LWfQeRcB09zBuQ3pfJ+fbI/YdDs0HTdoaciZqTP60p6OAkE0KaWNrM=,iv:FQXcR54qLMRbc/cQMJEITSYpgSgQARTKfW4tE/SbMLw=,tag:BylIfPjrLU1dVSMCy3kbqw==,type:comment] +#ENC[AES256_GCM,data:KC3yafMgOffxVnAdpAe1LENaKR/n6nBIB1VQQ0Uztpd9xybL/mdA4wIaRKKWSjskk4aUuBPNS3+BMBVi5JY=,iv:GwFke3iE7uBknZrjK5VwdjBd/acMkZo9l3rO49FLT4E=,tag:gSaPVKjpnIcrHxqCRCW7cw==,type:comment] +#ENC[AES256_GCM,data:aBavO38rZxezRadv93C9u2dmMqwMjMCCBsrai1Rjnb61ETh5Pp0zPOZpWL0TfpC6WXzQohfzzKfVd+mgNIZosnjQvImczBskiw==,iv:BerCOSJAvpMKcg8iolrs34LHNXXFs8gtrZXFrT6qUMY=,tag:ZSEEU/vh7HSYQCmWmkzkCQ==,type:comment] +#ENC[AES256_GCM,data:4GPACB4Ei34ZB0OcsoBl/AOzbHRCaIurMfozHnaEw9f0TchTtTUMP2+zine5xC6lYAzqEvOP,iv:zIm06VfOEo2FMS6KLra1WY4sEzuENGYiufGb/GKV618=,tag:UdwbwanpouKvLZsB9feARg==,type:comment] +#ENC[AES256_GCM,data:lBiJFtXX5TUBON+DusqLVVJaLXQ1QfycFxT7U2jKNw+aiKdy1CttBn9+ahc7pHdgLyBTym8DAaBm/gM1Zf82Ma/f5v4MF1qQVA==,iv:n1v7zPvdYin+z/knfeXc0c3YKygwMAlu2vDXkZRdp3k=,tag:/dxDxMz+luICJAeLiG9vPw==,type:comment] +#ENC[AES256_GCM,data:iD2Po4HE/hKHPWJAFrDp5F/dv6TWiq7NBINEh3LTt3B70b8yHdmRHPdRidvrxKUAuEM207NkiJLjlmJhCsswfojv5d1EIk48/l/Nnuk=,iv:lzqpigoVL77TOcrxgORHCqlJ89V6zdzAG2YTVYQfwSA=,tag:C+9LhztZ2+qjaai2pC6elg==,type:comment] +TOKEN=ENC[AES256_GCM,data:EvcddB9qdbhz76hdrtuSYl7BSkjcQBhbYNeXeg==,iv:QvlyKgwGOzXKbG2L9xIzwQxCBxdmpBi+ajq3dzwyE9A=,tag:0I1L/Cp2K8l6dgxs6EKLkw==,type:str] +sops_age__list_0__map_enc=-----BEGIN AGE ENCRYPTED FILE-----\nYWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBadGN3cWU2VFpHUWZyVFZ4\nV295SFpRMXhwLzdBaGM5YVBqeVZIRVp6R21FCm1JbmczaXJjR0xVSm1QQTliTWVh\nLzk4Y2NVWEl3RmlzYzc2N3VBeTdlalUKLS0tIHg0d3ZOTmw0Sm9sREFlaVYyR1Ux\nT1M2MGYxd2F4RFlVU0xncXROQlZJMm8KUCISMmjbibNyXY+slPVKZGG1vTO7JyJD\nnapIG4ZGwm73h1k37SU0VkPWo0hHWSh+GO9tAYly4ZHbtRGYX41Jiw==\n-----END AGE ENCRYPTED FILE-----\n +sops_age__list_0__map_recipient=age13l2gtk0nzr484zprp7e0pkrt0ne0j4asyn2pjmlaw73nte7t7d8q4sqtxm +sops_lastmodified=2026-10-14T14:08:14Z +sops_mac=ENC[AES256_GCM,data:pSe/FNOAYG3OL1q5aIO6DiUZdKqPKdTqYzCS5cnk5V5FOQU/C8R44ZNZ+Pky6LWLtmpKG07PO6aC9p79pWmj0abJW4eyO3KekMjqm+lbbwPLqGj0r2hcogNdKfLNFTyAoQ8cnrZCR+Jc6vPxAP9cn1/OvgFCat5f3Uc3y/nm8wA=,iv:NwIHt8Xa/O7ndgPiSlPd0ZlPnITwjhP/7BwRe0fWFXE=,tag:xcMIT6plRGgfh5XxBnUzcA==,type:str] +sops_unencrypted_suffix=_unencrypted +sops_version=3.13.3 diff --git a/secrets/gitea-runner-registration.yaml b/secrets/gitea-runner-registration.yaml deleted file mode 100644 index 6619cf5..0000000 --- a/secrets/gitea-runner-registration.yaml +++ /dev/null @@ -1,28 +0,0 @@ -#ENC[AES256_GCM,data:aOn5au0OYrlboc8lPN4riK+yyfMrdlEg8I23FDksEn8iA9BKvfNWkJYI3mhOuY9DYgyGY0NjiEdJsmZC2P5SbT3uGPUh58jKpQ==,iv:qGGP06LitnNyXKEDRumQmEfdahe+kPykIMzfBB8cT3s=,tag:qSp0k681locQ/WGwsxyYug==,type:comment] -#ENC[AES256_GCM,data:by+U93LnItOZj9e7dBwW2D07tDRczKm4h57dpGHl/LSUXlfOVdihFSMU8UqkW6CRI5hFVx5d6oQ0yOUiKwYweaJuLlm5+ztt0unwrOHAydsTKdFUazI=,iv:2ya7vu2yxmOyLYlqQsyt8hmB41d4yrj9azAVjAQws8c=,tag:HVY/rjBDIpAgjxuoW4ucDg==,type:comment] -#ENC[AES256_GCM,data:7Zekq/qMpSMO85IbZNoG4Rm60AWKRV1nIwNYafIoc7+FD3vxvO0do99f2Av7V30=,iv:iC8fa/jZ/CTyuLhSD3NtxtEFZFjfjqyPZSnJc6Sg/ws=,tag:8wjoCuHkXSnGn3ZhuKdwlQ==,type:comment] -#ENC[AES256_GCM,data:gMN0ghBmg/F9ZoH3RrKLuNkMUJNLEM3MDbT4b51iOM0Q53eL3JJWrhH+8BxfqMe9AQbLw2KqQM+7cMCqkbbvJa/KSwgrDg==,iv:HIaR/KlXv/fnqSKHn7gVJYXia7K2hAaRNVVSQfvD7yg=,tag:XfH7mEVaZIp5dx0YYYnA3g==,type:comment] -#ENC[AES256_GCM,data:2VpxbWAxN+XA4ArrrZx7MlmFEEBLiKfzOlYUSc4zZni5cIqeSPdkYCtQvo23ke3wRJ7tlAX4ddl2EEHbkOWFf96zPF+nWsnkc94=,iv:6goGKvlkN98KZfsxG+90q6fvAhgCT5fmQY1mpAaVhdQ=,tag:tdExRdkrvHgbotQHUxqIzw==,type:comment] -#ENC[AES256_GCM,data:Uf8hanI1hThM3JX74+RuWeeH9z88t8XHw4l/TU6rFY6LwxESA0+n9zsIm1eFbRaiHlPkczgaq+coGA4=,iv:xvM6uGVsFhUdbZLFMuqfUILedPqhuaGLqIHrXivQZyc=,tag:qm01JkJfJgwn++rYgMjS1A==,type:comment] -#ENC[AES256_GCM,data:5UxeydcHqQHaQc0pxvkc2goflB6xh914DrKbukFQfKcNsnzHrrbZAtt6p2sO1vHGBg6//nfS8gqGAJHgmOk3IWYWBRKK1A5ZL5s=,iv:MD/w4PGhxV+hN7ff46NuWFYdcNbDdEzm2zvqfjydV8E=,tag:DUcZM/O4R/S10XT+T1hojA==,type:comment] -#ENC[AES256_GCM,data:Zng9jlwNDmQwfXnUQIgLxkVaSwQHA/WlVQaXgS30Mrqlmr/jcTZJlnJTDll3F/Xg5Yid7D8oLZfsbmgzA9oC,iv:1Bb9m0pO09upy4jr01xoKzn1OVFXODpxhg6KNGZuxcE=,tag:wTqgKSLhkABX4sToDJKolw==,type:comment] -# -#ENC[AES256_GCM,data:6Uv81iII9UXQJhbCbbJrsUUxYvIo5cI5OOQ8Oflq3Xrh/F9qd8QY4Zny3HWLcD9+skDkPtOfw6gwJNp/BWe1zOc2ek+Xwy2+,iv:MExqcicsmglqYy7oFflia6xbS6WpfC+0gpDtBVGnExg=,tag:hpldOGze+OWGBmS+7FI2cQ==,type:comment] -#ENC[AES256_GCM,data:qNSQA9K5FN3m7r1QyfjQjtPbefYny40IXhLiNrhuOVOtfw4BIxPclHssB74XoVjKJzOrFN+NZUng2oljfcEeJawCzBg7Nur/,iv:kfJ/cxg0MO1FA0INJKW4f5ezabhhGRUJ0MEQBI69tEA=,tag:FO/g4g19vo9H2MZGRh8QtQ==,type:comment] -#ENC[AES256_GCM,data:wIVfm8l/NxBVXqT8YdM4AVPiT496E0Z2sEAem8ROkX3KbVKxV/jsCd4G8gh7KP6FmZb2njgNEo6pDKJm8NAlWYUT5mzDY9gx,iv:1MDTVu78R3ssFqhqWv9tE0fpdlDvKneuZZEy068mKMM=,tag:dcbOFo2IY0jUkfzpnRhbUQ==,type:comment] -registration_token: ENC[AES256_GCM,data:F4u0NQ+jZ4eGyqzyJwXwtOzP9+lmRUxu5TdhE/eGKbXoRO4O8UAQQQ==,iv:xV/h3piPHU+24fZOr01bVxA7EHsy2nLlnhHLNI8C4Io=,tag:kFas/6csd8a7VDupLzJazA==,type:str] -sops: - age: - - enc: | - -----BEGIN AGE ENCRYPTED FILE----- - YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBoREQvTU5ZODM4YWc5ODhL - TEI2M0J1OGdXQ0x0SElUQXVGMFhYTEhQUFN3CkZWUXFsR0hQdk5BNiswMk9YeERP - YmY3QUxaMFI1aGZUbHh3eXBHUUQzQ0UKLS0tIHprVlRKUDB3dFdFSDkzeitrY0sr - MkFhcEx3Ni8xMjJ5UUkvL3VQeG5IMkkKT7Y81d36kQkKRojv5CwVpMY75NKaqn4y - NYmasliQYCQeah1rsNBbFhLdIJUMkrSzqldVRuiQHlZMo0WKj1LLhA== - -----END AGE ENCRYPTED FILE----- - recipient: age13l2gtk0nzr484zprp7e0pkrt0ne0j4asyn2pjmlaw73nte7t7d8q4sqtxm - lastmodified: "2026-10-14T13:13:57Z" - mac: ENC[AES256_GCM,data:rTO+IhDkGLTcHNcagDEeswLdmITisdz3Xts//ndkz5iZYhZXSLoh23Z+PwzSHjop49L+fsZebyeQlfONhuKFLd+qRLz6NTEb+yd4vHin1c5Lr1TUEvXBKRZViqweMKAudfcNYZL73gvbkhCfyj8131arY2RPD/NYd0L4KRigUpA=,iv:usVkK4b3BXhxtw1bZ751smz22jVT1Ld5DFOH8ZHA9gI=,tag:nsoL0INpoNiLD4p7dp91cg==,type:str] - unencrypted_suffix: _unencrypted - version: 3.13.3