mirror of
https://github.com/Mic92/sops-nix.git
synced 2026-07-17 14:35:25 +08:00
sops-install-secrets: call systemctl directly when run as a systemd unit
When useSystemdActivation is enabled, sops-install-secrets.service runs ordered Before=sysinit-reactivation.target, which switch-to-configuration restarts *after* it has already consumed /run/nixos/activation-*-list. Writing to those files from the service therefore does nothing on the current switch and leaks into the next one. NixOS 26.05 also deprecates the activation-list mechanism, printing a warning whenever the files exist, with removal planned for 26.11. The systemd unit now sets SOPS_RESTART_UNITS_VIA_SYSTEMCTL=1 so the binary knows to call systemctl directly (try-restart / try-reload-or-restart, --no-block to avoid deadlocking the sysinit transaction). INVOCATION_ID cannot be used for this since switch-to-configuration is almost always invoked from a process tree rooted in some unit (sshd, getty, systemd-run), so the activation script inherits it too. The legacy activation-script path keeps writing the list files for backward compatibility. Closes #934
This commit is contained in:
parent
c591bf6657
commit
81440e3757
3 changed files with 88 additions and 28 deletions
|
|
@ -475,7 +475,9 @@ in
|
|||
];
|
||||
requiredBy = [ "sysinit-reactivation.target" ];
|
||||
before = [ "sysinit-reactivation.target" ];
|
||||
environment = cfg.environment;
|
||||
environment = cfg.environment // {
|
||||
SOPS_RESTART_UNITS_VIA_SYSTEMCTL = "1";
|
||||
};
|
||||
unitConfig.DefaultDependencies = "no";
|
||||
path = cfg.age.plugins;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue