Hello!
I’m wondering what’s the proper way to have local only packages that don’t interfere with git / rebasing / changing branches / recompilation.
I’ve seen Proper way to have a local, non-commitable addition to runtime.exs, but this is only about configuration.
For example, I’d like to install the following packages for my “personal” use (until at least the use case is validated to train other colleagues on them):
- dialixir
- mix-test.watch (which is the latest package I wanted to add for my own quality of life)
Until now, I’ve added them in my local env in mix.exs
but this is tedious when changing branches, they get in the way of my stashes, etc. Every time I rebase/change branch, I have to recompile the whole project (because mix.exs changed), and 1000+ files is long.
I’ve invested some time this morning to figure out if there would be a more dynamic approach, e.g. by having a .gitigore
d file, let’s call it mix_local.exs
.
What I have for now:
defmodule Project.Mixfile do
use Mix.Project
def project do
local_mix =
if File.exists?("mix_local.exs") do
Code.require_file("mix_local.exs")
Project.MixfileLocal
else
%{
project: fn -> [] end,
deps: fn -> [] end
}
end
[
# ...
deps: deps() ++ local_mix.deps()
] ++ local_mix.project()
end
defmodule Project.MixfileLocal do
def project do
[
lockfile: "mix_local.lock"
]
end
def deps do
[
{:mix_test_watch, "~> 1.0", only: [:dev, :test], runtime: false}
]
end
end
It’s a good start, I can add my own dependencies, but now the mix_local.lock
file contains all the dependencies from the normal config + the newly added one. This means that when I pull an updated mix.lock
it won’t be used and I risk differences in the lockfiles.
Would there be a way for my mix_local.lock
to only contain the dependencies that I added in mix_local.exs
?