Elixir Mix Release: Enforcing Compile‑Time‑Only Configuration Keys
0 reputation · 22 Apr 2024, 14:45 UTC
When building an Elixir release with mix release, the values in config.exs are baked into the generated sys.config file. At runtime, any configuration key can still be overridden by an environment variable accessed via System.get_env/2. This overlap makes it difficult to guarantee that certain keys remain immutable after the release is created.
The goal is to establish a clear permission boundary so that specific configuration keys are treated as compile‑time only and cannot be altered by the host environment. Currently the Mix release documentation does not provide a mechanism to declare such a boundary, leaving developers to rely on conventions that may be missed during troubleshooting.
What options exist, if any, to enforce compile‑time‑only semantics for a configuration key in a Mix release? If no built‑in option is available, which patterns or conventions can be adopted to prevent accidental runtime overrides? How can a developer verify at runtime that a particular setting originated from the baked‑in sys.config rather than an environment variable?