-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmix.exs
144 lines (123 loc) · 3.41 KB
/
mix.exs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
defmodule Proxy.Mixfile do
use Mix.Project
#config = Mix.Config.read!("config.exs")
#sys_config_string = :io_lib.format('~p.~n', [config]) |> List.to_string
#File.write("sys.config", sys_config_string)
def version, do: "0.0.2"
def project do
[
#app: :proxy,
apps_path: "apps",
apps: [
:admin_console,
:http_proxy,
:i2pdctl,
:out_proxy,
],
version: version(),
elixir: "~> 1.9",
build_embedded: Mix.env == :prod,
start_permanent: Mix.env == :prod,
elixirc_paths: elixirc_paths(Mix.env),
releases: [
proxy: release()
],
compilers: [:phoenix] ++ Mix.compilers(),
preferred_cli_target: [run: :host, test: :host],
aliases: aliases(),
deps: deps()
]
end
defp hostname do
System.cmd("hostname", []) |> elem(0) |> String.trim
end
# Specifies which paths to compile per environment.
defp elixirc_paths(:test), do: ["lib", "test/support"]
defp elixirc_paths(_), do: ["lib"]
defp aliases do
[
#build: [ &build_releases/1],
outdated: [ "hex.outdated" ]
]
end
def application do
[
applications: [
:crypto,
:logger,
:http_proxy,
:out_proxy,
]
]
end
def release do
[
include_erts: true,
include_executables_for: [:unix],
applications: [
#runtime_tools: :permanent,
admin_console: :permanent,
http_proxy: :permanent,
i2pdctl: :permanent,
out_proxy: :permanent,
],
overwrite: true,
cookie: "#{:proxy}_cookie",
nodename: "private-outproxy",
#include_erts: &Nerves.Release.erts/0,
#steps: [&Nerves.Release.init/1, :assemble]
]
end
defp no_proxy_env() do
System.get_env("NO_PROXY") || System.get_env("no_proxy")
end
defp no_proxy_list(nil) do
[]
end
defp no_proxy_list(no_proxy) do
no_proxy
|> String.split(",")
|> Enum.map(&String.to_charlist/1)
end
defp proxy_setup(scheme, proxy, no_proxy) do
uri = URI.parse(proxy || "")
if uri.host && uri.port do
host = String.to_charlist(uri.host)
:httpc.set_options([{proxy_scheme(scheme), {{host, uri.port}, no_proxy}}], :mix)
end
uri
end
defp proxy_scheme(scheme) do
case scheme do
:http -> :proxy
:https -> :https_proxy
end
end
defp proxy_env do
http_proxy = System.get_env("HTTP_PROXY") || System.get_env("http_proxy")
https_proxy = System.get_env("HTTPS_PROXY") || System.get_env("https_proxy")
no_proxy = no_proxy_env() |> no_proxy_list()
{proxy_setup(:http, http_proxy, no_proxy), proxy_setup(:https, https_proxy, no_proxy)}
end
defp deps do
[
{:plug, "~> 1.8", override: true},
{:plug_cowboy, "~> 1.0", override: true},
{:phoenix, "~> 1.4", override: true},
{:poison, "~> 4.0", override: true},
{:httpoison, "~> 1.6.2", override: true},
#{:ffi, git: "https://github.com/joshnuss/elixir-ffi.git"},
{:norma, ">= 0.0.0"},
{:vapor, "~> 0.2"},
{:tzdata, "~> 1.0", override: true},
# Development stuff
{:observer_cli, "~> 1.5"},
{:mix_docker, "~> 0.5.0"},
{:mix_systemd, "~> 0.5.0"},
#{:edeliver, ">= 1.6.0"},
{:distillery, "~> 2.1.1", override: true},
{:git_hooks, "~> 0.3.2-pre3", only: [:test, :dev], runtime: false},
{:akd, "~> 0.2.2", only: :dev, runtime: false},
]
end
end