rclone: make requiresUnit read-only on non-systemd platforms

The option only feeds the systemd config-install service; on Darwin the
launchd agent ignores it, and on any other non-Linux platform the
option is similarly inert. Marking it readOnly with a null default
when systemd is unavailable prevents users from setting a value that
would silently do nothing, and surfaces the platform constraint in the
option itself rather than only in the description.
This commit is contained in:
jiezhuzzz 2026-05-06 12:55:01 -05:00 committed by Austin Horstman
parent 8da35b6f14
commit fd272ce76e

View file

@ -489,17 +489,21 @@ in
requiresUnit = lib.mkOption {
type = with lib.types; nullOr str;
readOnly = !pkgs.stdenv.hostPlatform.isLinux;
default =
lib.foldlAttrs
(
acc: prov: svc:
if isUsingSecretProvisioner prov then svc else acc
)
if !pkgs.stdenv.hostPlatform.isLinux then
null
{
"sops" = "sops-nix.service";
"age" = "agenix.service";
};
else
lib.foldlAttrs
(
acc: prov: svc:
if isUsingSecretProvisioner prov then svc else acc
)
null
{
"sops" = "sops-nix.service";
"age" = "agenix.service";
};
example = "agenix.service";
description = ''
The name of a systemd user service that must complete before the rclone
@ -512,10 +516,11 @@ in
sops-nix.service or agenix.service, respectively. Set this manually if you
use a different secret provisioner.
Ignored on macOS, since launchd has no equivalent ordering primitive.
The config-install agent retries on failure (KeepAlive.Crashed), so it
will succeed on a subsequent attempt once the secret-provisioner agent
has materialized the secret files.
Read-only on non-systemd platforms (always null), since this option
has no equivalent ordering primitive outside systemd. On macOS, the
config-install launchd agent retries on failure (KeepAlive.Crashed),
so it will succeed on a subsequent attempt once the secret-provisioner
agent has materialized the secret files.
'';
};
};