Skip to content

Commit 645fa1c

Browse files
committed
modules/sops: re-run sops-install-secrets.service at sysinit-reactivation.target
Consider the following case: a service (`gitlab-runner.service` in this case) gets a new secret that is installed via sops and will be reloaded on a switch. Right now this would fail like this: machine | updating GRUB 2 menu... machine | stopping the following units: sops-install-secrets.service machine | activating the configuration... machine | setting up /etc... [...] machine | restarting sysinit-reactivation.target machine | reloading the following units: dbus-broker.service, gitlab-runner.service machine | restarting the following units: polkit.service machine | starting the following units: sops-install-secrets.service Here, the reload happens _before_ running `sops-install-secrets.service` which means that the newly added secret doesn't exist yet and thus the reload fails. This change makes sure the service is started when running `sysinit-reactivation.target`, i.e. before stc-ng reloads other services. This is what sysusers already does, so the objective of running after sysusers is still met. Also, added an `After=userborn.service` to make sure it's also ordered after userborn if necessary. Thank you WilliButz for reminding me that `sysinit-reactivation.target` exists and is most likely the culprit of that!
1 parent 7fd1416 commit 645fa1c

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

modules/sops/default.nix

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,9 @@ in
448448
# When using sysusers we no longer are started as an activation script because those are started in initrd while sysusers is started later.
449449
systemd.services.sops-install-secrets = lib.mkIf (regularSecrets != { } && cfg.useSystemdActivation) {
450450
wantedBy = [ "sysinit.target" ];
451-
after = [ "systemd-sysusers.service" ];
451+
after = [ "systemd-sysusers.service" "userborn.service" ];
452+
requiredBy = [ "sysinit-reactivation.target" ];
453+
before = [ "sysinit-reactivation.target" ];
452454
environment = cfg.environment;
453455
unitConfig.DefaultDependencies = "no";
454456

0 commit comments

Comments
 (0)