Skip to content

Commit

Permalink
Only add appConfigPath to mix builds
Browse files Browse the repository at this point in the history
  • Loading branch information
camelpunch committed Dec 1, 2024
1 parent cd984ba commit 165532a
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 16 deletions.
12 changes: 0 additions & 12 deletions fixtures/example/deps.nix
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ let
buildRebar3 {
inherit version;
name = "acceptor_pool";
appConfigPath = ./config;

src = fetchHex {
inherit version;
Expand All @@ -142,7 +141,6 @@ let
buildRebar3 {
inherit version;
name = "aws_signature";
appConfigPath = ./config;

src = fetchHex {
inherit version;
Expand Down Expand Up @@ -199,7 +197,6 @@ let
buildRebar3 {
inherit version;
name = "chatterbox";
appConfigPath = ./config;

src = fetchHex {
inherit version;
Expand Down Expand Up @@ -240,7 +237,6 @@ let
buildRebar3 {
inherit version;
name = "ctx";
appConfigPath = ./config;

src = fetchHex {
inherit version;
Expand Down Expand Up @@ -560,7 +556,6 @@ let
buildRebar3 {
inherit version;
name = "gproc";
appConfigPath = ./config;

src = fetchHex {
inherit version;
Expand All @@ -576,7 +571,6 @@ let
buildRebar3 {
inherit version;
name = "grpcbox";
appConfigPath = ./config;

src = fetchHex {
inherit version;
Expand All @@ -599,7 +593,6 @@ let
buildRebar3 {
inherit version;
name = "hpack";
appConfigPath = ./config;

src = fetchHex {
inherit version;
Expand Down Expand Up @@ -720,7 +713,6 @@ let
buildRebar3 {
inherit version;
name = "opentelemetry";
appConfigPath = ./config;

src = fetchHex {
inherit version;
Expand Down Expand Up @@ -756,7 +748,6 @@ let
buildRebar3 {
inherit version;
name = "opentelemetry_exporter";
appConfigPath = ./config;

src = fetchHex {
inherit version;
Expand Down Expand Up @@ -817,7 +808,6 @@ let
buildRebar3 {
inherit version;
name = "png";
appConfigPath = ./config;

src = fetchHex {
inherit version;
Expand Down Expand Up @@ -970,7 +960,6 @@ let
buildRebar3 {
inherit version;
name = "telemetry";
appConfigPath = ./config;

src = fetchHex {
inherit version;
Expand Down Expand Up @@ -1006,7 +995,6 @@ let
buildRebar3 {
inherit version;
name = "tls_certificate_check";
appConfigPath = ./config;

src = fetchHex {
inherit version;
Expand Down
24 changes: 20 additions & 4 deletions lib/deps_nix/derivation.ex
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,7 @@ defmodule DepsNix.Derivation do
in
#{drv.builder} {
inherit version;
name = "#{drv.name}";
appConfigPath = #{format_path(drv.app_config_path)};
name = "#{drv.name}";#{format_app_config_path(drv)}
src = #{src(drv.src)}#{beam_deps(drv.beam_deps)}
};
Expand Down Expand Up @@ -174,8 +173,25 @@ defmodule DepsNix.Derivation do
|> Util.indent(from: 2)
end

defp format_path(path) do
if String.starts_with?(path, "."), do: path, else: "./#{path}"
defp format_app_config_path(%DepsNix.Derivation{
builder: "buildMix",
app_config_path: path
}) do
"\nappConfigPath = #{prefix_path(path)};"
|> Util.indent(from: 1)
|> Util.indent(from: 1)
end

defp format_app_config_path(_drv) do
""
end

defp prefix_path(<<".", _rest::binary>> = path) do
path
end

defp prefix_path(path) do
"./#{path}"
end
end
end
8 changes: 8 additions & 0 deletions test/deps_nix/derivation_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,14 @@ defmodule DepsNix.DerivationTest do
end

describe "string representation" do
test "rebar3 builds don't get appConfigPaths" do
refute dep(builders: [:rebar3], scm: Mix.SCM.Hex)
|> pick()
|> Derivation.from(%DepsNix.Options{})
|> to_string()
|> String.contains?("appConfigPath")
end

test "paths get special treatment" do
assert %Derivation{
builder: "buildMix",
Expand Down

0 comments on commit 165532a

Please sign in to comment.