Skip to content

Commit 165532a

Browse files
committed
Only add appConfigPath to mix builds
1 parent cd984ba commit 165532a

File tree

3 files changed

+28
-16
lines changed

3 files changed

+28
-16
lines changed

fixtures/example/deps.nix

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ let
126126
buildRebar3 {
127127
inherit version;
128128
name = "acceptor_pool";
129-
appConfigPath = ./config;
130129

131130
src = fetchHex {
132131
inherit version;
@@ -142,7 +141,6 @@ let
142141
buildRebar3 {
143142
inherit version;
144143
name = "aws_signature";
145-
appConfigPath = ./config;
146144

147145
src = fetchHex {
148146
inherit version;
@@ -199,7 +197,6 @@ let
199197
buildRebar3 {
200198
inherit version;
201199
name = "chatterbox";
202-
appConfigPath = ./config;
203200

204201
src = fetchHex {
205202
inherit version;
@@ -240,7 +237,6 @@ let
240237
buildRebar3 {
241238
inherit version;
242239
name = "ctx";
243-
appConfigPath = ./config;
244240

245241
src = fetchHex {
246242
inherit version;
@@ -560,7 +556,6 @@ let
560556
buildRebar3 {
561557
inherit version;
562558
name = "gproc";
563-
appConfigPath = ./config;
564559

565560
src = fetchHex {
566561
inherit version;
@@ -576,7 +571,6 @@ let
576571
buildRebar3 {
577572
inherit version;
578573
name = "grpcbox";
579-
appConfigPath = ./config;
580574

581575
src = fetchHex {
582576
inherit version;
@@ -599,7 +593,6 @@ let
599593
buildRebar3 {
600594
inherit version;
601595
name = "hpack";
602-
appConfigPath = ./config;
603596

604597
src = fetchHex {
605598
inherit version;
@@ -720,7 +713,6 @@ let
720713
buildRebar3 {
721714
inherit version;
722715
name = "opentelemetry";
723-
appConfigPath = ./config;
724716

725717
src = fetchHex {
726718
inherit version;
@@ -756,7 +748,6 @@ let
756748
buildRebar3 {
757749
inherit version;
758750
name = "opentelemetry_exporter";
759-
appConfigPath = ./config;
760751

761752
src = fetchHex {
762753
inherit version;
@@ -817,7 +808,6 @@ let
817808
buildRebar3 {
818809
inherit version;
819810
name = "png";
820-
appConfigPath = ./config;
821811

822812
src = fetchHex {
823813
inherit version;
@@ -970,7 +960,6 @@ let
970960
buildRebar3 {
971961
inherit version;
972962
name = "telemetry";
973-
appConfigPath = ./config;
974963

975964
src = fetchHex {
976965
inherit version;
@@ -1006,7 +995,6 @@ let
1006995
buildRebar3 {
1007996
inherit version;
1008997
name = "tls_certificate_check";
1009-
appConfigPath = ./config;
1010998

1011999
src = fetchHex {
10121000
inherit version;

lib/deps_nix/derivation.ex

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,7 @@ defmodule DepsNix.Derivation do
143143
in
144144
#{drv.builder} {
145145
inherit version;
146-
name = "#{drv.name}";
147-
appConfigPath = #{format_path(drv.app_config_path)};
146+
name = "#{drv.name}";#{format_app_config_path(drv)}
148147
149148
src = #{src(drv.src)}#{beam_deps(drv.beam_deps)}
150149
};
@@ -174,8 +173,25 @@ defmodule DepsNix.Derivation do
174173
|> Util.indent(from: 2)
175174
end
176175

177-
defp format_path(path) do
178-
if String.starts_with?(path, "."), do: path, else: "./#{path}"
176+
defp format_app_config_path(%DepsNix.Derivation{
177+
builder: "buildMix",
178+
app_config_path: path
179+
}) do
180+
"\nappConfigPath = #{prefix_path(path)};"
181+
|> Util.indent(from: 1)
182+
|> Util.indent(from: 1)
183+
end
184+
185+
defp format_app_config_path(_drv) do
186+
""
187+
end
188+
189+
defp prefix_path(<<".", _rest::binary>> = path) do
190+
path
191+
end
192+
193+
defp prefix_path(path) do
194+
"./#{path}"
179195
end
180196
end
181197
end

test/deps_nix/derivation_test.exs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,14 @@ defmodule DepsNix.DerivationTest do
236236
end
237237

238238
describe "string representation" do
239+
test "rebar3 builds don't get appConfigPaths" do
240+
refute dep(builders: [:rebar3], scm: Mix.SCM.Hex)
241+
|> pick()
242+
|> Derivation.from(%DepsNix.Options{})
243+
|> to_string()
244+
|> String.contains?("appConfigPath")
245+
end
246+
239247
test "paths get special treatment" do
240248
assert %Derivation{
241249
builder: "buildMix",

0 commit comments

Comments
 (0)