|
29 | 29 | # Currently, all templates are "regular" (there's no support for `neededForUsers` for templates.) |
30 | 30 | regularTemplates = cfg.templates; |
31 | 31 |
|
32 | | - useSystemdActivation = |
33 | | - (options.systemd ? sysusers && config.systemd.sysusers.enable) |
34 | | - || (options.services ? userborn && config.services.userborn.enable); |
35 | | - |
36 | 32 | withEnvironment = import ./with-environment.nix { |
37 | 33 | # sops >=3.10.0 now unconditionally searches |
38 | 34 | # for an SSH key in $HOME/.ssh/, introduced in #1692 [0]. Since in the |
|
319 | 315 | ''; |
320 | 316 | }; |
321 | 317 |
|
| 318 | + useSystemdActivation = lib.mkOption { |
| 319 | + type = lib.types.bool; |
| 320 | + default = |
| 321 | + (options.systemd ? sysusers && config.systemd.sysusers.enable) |
| 322 | + || (options.services ? userborn && config.services.userborn.enable); |
| 323 | + defaultText = lib.literalExpression ( |
| 324 | + "(options.systemd ? sysusers && config.systemd.sysusers.enable) " |
| 325 | + + "|| (options.services ? userborn && config.services.userborn.enable)" |
| 326 | + ); |
| 327 | + description = '' |
| 328 | + Use a systemd unit to install secrets, instead of deploying them using an activation script. |
| 329 | +
|
| 330 | + This option is automatically enabled when systemd-sysusers or userborn are used to manage users and groups. |
| 331 | + It can also be useful to specify additional dependencies to be satisfied before secrets are installed, such as required mountpoints for SOPS key files. |
| 332 | + ''; |
| 333 | + }; |
| 334 | + |
322 | 335 | age = { |
323 | 336 | keyFile = lib.mkOption { |
324 | 337 | type = lib.types.nullOr pathNotInStore; |
|
433 | 446 | ); |
434 | 447 |
|
435 | 448 | # When using sysusers we no longer are started as an activation script because those are started in initrd while sysusers is started later. |
436 | | - systemd.services.sops-install-secrets = lib.mkIf (regularSecrets != { } && useSystemdActivation) { |
| 449 | + systemd.services.sops-install-secrets = lib.mkIf (regularSecrets != { } && cfg.useSystemdActivation) { |
437 | 450 | wantedBy = [ "sysinit.target" ]; |
438 | 451 | after = [ "systemd-sysusers.service" ]; |
439 | 452 | environment = cfg.environment; |
|
447 | 460 | }; |
448 | 461 |
|
449 | 462 | system.activationScripts = { |
450 | | - setupSecrets = lib.mkIf (regularSecrets != { } && !useSystemdActivation) ( |
| 463 | + setupSecrets = lib.mkIf (regularSecrets != { } && !cfg.useSystemdActivation) ( |
451 | 464 | lib.stringAfter |
452 | 465 | ( |
453 | 466 | [ |
|
0 commit comments