diff --git a/nix/agent-modules/otel.nix b/nix/agent-modules/otel.nix index e4ff3200..95a432cf 100644 --- a/nix/agent-modules/otel.nix +++ b/nix/agent-modules/otel.nix @@ -234,7 +234,15 @@ in # host-persisted state bind mount: it indexes /var/log/journal, # itself fresh on every container recreate, so the two must share # a lifetime or the cursor outlives the journal it points into. - extensions.file_storage.directory = "/var/lib/opentelemetry-collector"; + # `create_directory` matters here for a build-time-vs-runtime + # reason, not a convenience one: `validateConfigFile` above runs + # `otelcol validate` in the nix build sandbox, before systemd's + # `StateDirectory=` has ever created this path. Without it the + # validator refuses with "directory must exist" and the build fails. + extensions.file_storage = { + directory = "/var/lib/opentelemetry-collector"; + create_directory = true; + }; receivers.journald = { # ⚠️ STATED, and it must stay stated: the receiver's own default