ademenev

ademenev

How to use an app as a dependency and reuse its config?

I have an application, lets call it A, that is in its own repo and has some configuration, and can run on its own. I want to create another application B that extends the functionality of A (A already provides some extension points). My idea is to use A as a dependency of B. The configuration of B must be inherited from A, so B can start it without having to redefine the config. Is it a good idea to just import A’s config into B’s config?

Most Liked

derek-zhou

derek-zhou

I’d just copy the config file content because:

  • Eventually, the config will diverge.
  • If their is a large part of config that is static, maybe it is better to refactor it into code.

Last Post!

ademenev

ademenev

So what’s the issue with this? Seems to work just fine

b/config/config.exs

import Config

import_config "../../a/config/config.exs"

b/mix.exs

  defp deps do
    [
      {:a, path: "../a"}
    ]
  end

If somewhere in A I am using for example Application.fetch_env!(:a, :x), then it works just fine when A is started both directly and as dependency of B. And B expectedly fails when I remove that import from its config

Where Next?

Popular in Questions Top

jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
Emily
I have VueJS GUIs with the project generated using Webpack. I have Elixir modules that will need to be used by the VueJS GUIs. I forese...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New

Other popular topics Top

baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
New
AstonJ
Seen any cool LiveView demos, sample apps or examples? Please post them here! :003:
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
AstonJ
Posting this to see if we can make things easier for people to get into Neovim. If you use Neovim and have a favourite distro please let ...
New

We're in Beta

About us Mission Statement