Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion fixtures/example/deps.nix
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ let
name = "rustlerPrecompiled";
toolchain = {
name = "nightly-2025-06-23";
sha256 = "sha256-UAoZcxg3iWtS+2n8TFNfANFt/GmkuOMDf7QAE0fRxeA=";
sha256 = "sha256-UAoZcxg3iWtS+2n8TFNfANFt/GmkuOMDf7QAE0fRxeA=";
};
}
];
Expand Down
14 changes: 13 additions & 1 deletion lib/deps_nix/derivation.ex
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,20 @@ defmodule DepsNix.Derivation do
{:hex, name, version, _hash, beam_builders, _sub_deps, _, sha256} = dep.opts[:lock]
fetcher = %FetchHex{pkg: name, version: version, sha256: sha256}

builder =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no test covering this change. I'd prefer to remove the implementation of this nil check, over having no test. Sorry for being fussy!

Copy link
Contributor Author

@adamcstephens adamcstephens Mar 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this because previously the cond below was not matching and the error was very unclear when troubleshooting why deps_nix was crashing. So this is error handling for users and potential new builders being introduced, as no cond clause evaluated to a truthy value provides no indication why its failing and on which dep.

How do you propose to test a code path that calls System.halt?

case nix_builder(beam_builders) do
nil ->
IO.puts("Unknown builders #{inspect(beam_builders)} for dep: #{name}")
System.halt(1)

builder ->
builder
end

new(dep,
version: version,
src: fetcher,
builder: nix_builder(beam_builders),
builder: builder,
app_config_path: app_config_path(options)
)
end
Expand All @@ -119,6 +129,8 @@ defmodule DepsNix.Derivation do
cond do
Enum.member?(builders, :mix) -> "buildMix"
Enum.member?(builders, :rebar3) -> "buildRebar3"
Enum.member?(builders, :make) -> "buildErlangMk"
true -> nil
end
end

Expand Down
6 changes: 6 additions & 0 deletions test/deps_nix/derivation_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,12 @@ defmodule DepsNix.DerivationTest do
end
end

property "selects buildErlangMk for :make builder" do
check all dep <- dep(scm: Mix.SCM.Hex, builders: [:make]) do
assert %Derivation{builder: "buildErlangMk"} = Derivation.from(dep, %DepsNix.Options{})
end
end

test "doesn't include optional dependencies in beamDeps" do
eventstore =
%Mix.Dep{
Expand Down
Loading