Can I use a Config.Provider without using a mix release?

I wish to run a config provider before runtime.exs kicks in so I can alter the config dynamically on start up. Is this possible to do with a config provider?

The docs say to use a config provider you have to do this in the mix.exs

releases: [
  demo: [
    config_providers: [...]

which implies I have to use a release.

You could theoretically not define a provider and instead invoke whatever code you need from runtime.exs. That should also work for Mix and releases.


Yea that’s true! I can also set config in the application.ex too I suppose.

When I did Application.get_all_env(:my_app) in runtime.exs it didn’t seem like the config in runtime was set yet, unlike in application.ex:

import Config
config(:my_app, thing: 1)
# This is []

The use case is having templates for secrets in the config:

  magic_number: {"GOOGLE_SECRET", :integer, "MY_SECRET_NUMBER"}

The config provider would parse that, get the secret from wherever (eg google) and replace the tuple with the actual secret value.

I guess defining my own fn like this would work:

  magic_number: {"GOOGLE_SECRET", :integer, "MY_SECRET_NUMBER"}