nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 stdenvNoCC,
3 lib,
4 elixir,
5 hex,
6 rebar,
7 rebar3,
8 cacert,
9 git,
10}@inputs:
11
12{
13 pname,
14 version,
15 hash ? "",
16 sha256 ? "",
17 src,
18 mixEnv ? "prod",
19 mixTarget ? "host",
20 debug ? false,
21 meta ? { },
22 patches ? [ ],
23 elixir ? inputs.elixir,
24 hex ? inputs.hex.override { inherit elixir; },
25 ...
26}@attrs:
27
28let
29 hash_ =
30 if hash != "" then
31 {
32 outputHashAlgo = null;
33 outputHash = hash;
34 }
35 else if sha256 != "" then
36 {
37 outputHashAlgo = "sha256";
38 outputHash = sha256;
39 }
40 else
41 {
42 outputHashAlgo = "sha256";
43 outputHash = lib.fakeSha256;
44 };
45in
46stdenvNoCC.mkDerivation (
47 attrs
48 // {
49 nativeBuildInputs = [
50 elixir
51 hex
52 cacert
53 git
54 ];
55
56 MIX_ENV = mixEnv;
57 MIX_TARGET = mixTarget;
58 MIX_DEBUG = if debug then 1 else 0;
59 DEBUG = if debug then 1 else 0; # for rebar3
60 # the api with `mix local.rebar rebar path` makes a copy of the binary
61 MIX_REBAR = "${rebar}/bin/rebar";
62 MIX_REBAR3 = "${rebar3}/bin/rebar3";
63 # there is a persistent download failure with absinthe 1.6.3
64 # those defaults reduce the failure rate
65 HEX_HTTP_CONCURRENCY = 1;
66 HEX_HTTP_TIMEOUT = 120;
67
68 configurePhase =
69 attrs.configurePhase or ''
70 runHook preConfigure
71 export HEX_HOME="$TEMPDIR/.hex";
72 export MIX_HOME="$TEMPDIR/.mix";
73 export MIX_DEPS_PATH="$TEMPDIR/deps";
74
75 # Rebar
76 export REBAR_GLOBAL_CONFIG_DIR="$TMPDIR/rebar3"
77 export REBAR_CACHE_DIR="$TMPDIR/rebar3.cache"
78 runHook postConfigure
79 '';
80
81 inherit patches;
82
83 dontBuild = true;
84
85 installPhase =
86 attrs.installPhase or ''
87 runHook preInstall
88 mix deps.get ''${MIX_ENV:+--only $MIX_ENV}
89 find "$TEMPDIR/deps" -path '*/.git/*' -a ! -name HEAD -exec rm -rf {} +
90 cp -r --no-preserve=mode,ownership,timestamps $TEMPDIR/deps $out
91 runHook postInstall
92 '';
93
94 outputHashMode = "recursive";
95
96 impureEnvVars = lib.fetchers.proxyImpureEnvVars;
97 inherit meta;
98 }
99 // hash_
100)