15 nativeBuildInputs ? [ ],
16 erlangCompilerOptions ? [ ],
17 # Deterministic Erlang builds remove full system paths from debug information
18 # among other things to keep builds more reproducible. See their docs for more:
19 # https://www.erlang.org/doc/man/compile
20 erlangDeterministicBuilds ? true,
22 propagatedBuildInputs ? [ ],
26 enableDebugInfo ? false,
28 # A config directory that is considered for all the dependencies of an app, typically in $src/config/
29 # This was initially added, as some of Mobilizon's dependencies need to access the config at build time.
38 name = "interactive-shell-${drv.name}";
39 buildInputs = [ drv ];
47 name = "${name}-${version}";
51 MIX_DEBUG = if enableDebugInfo then 1 else 0;
54 ERL_COMPILER_OPTIONS =
56 options = erlangCompilerOptions ++ lib.optionals erlangDeterministicBuilds [ "deterministic" ];
58 "[${lib.concatStringsSep "," options}]";
62 # add to ERL_LIBS so other modules can find at runtime.
63 # http://erlang.org/doc/man/code.html#code-path
64 # Mix also searches the code path when compiling with the --no-deps-check flag
65 setupHook = attrs.setupHook or writeText "setupHook.sh" ''
66 addToSearchPath ERL_LIBS "$1/lib/erlang/lib"
69 buildInputs = buildInputs ++ [ ];
70 nativeBuildInputs = nativeBuildInputs ++ [
74 propagatedBuildInputs = propagatedBuildInputs ++ beamDeps;
77 attrs.configurePhase or ''
80 ${./mix-configure-hook.sh}
81 ${lib.optionalString (!isNull appConfigPath)
82 # Due to https://hexdocs.pm/elixir/main/Config.html the config directory
83 # of a library seems to be not considered, as config is always
84 # application specific. So we can safely delete it.
87 cp -r ${appConfigPath} config
95 attrs.buildPhase or ''
97 export HEX_HOME="$TEMPDIR/hex"
98 export MIX_HOME="$TEMPDIR/mix"
99 mix compile --no-deps-check
104 attrs.installPhase or ''
107 # This uses the install path convention established by nixpkgs maintainers
108 # for all beam packages. Changing this will break compatibility with other
109 # builder functions like buildRebar3 and buildErlangMk.
110 mkdir -p "$out/lib/erlang/lib/${name}-${version}"
112 # Some packages like db_connection will use _build/shared instead of
113 # honoring the $MIX_ENV variable.
114 for reldir in _build/{$MIX_ENV,shared}/lib/${name}/{src,ebin,priv,include} ; do
115 if test -d $reldir ; then
116 # Some builds produce symlinks (eg: phoenix priv dircetory). They must
117 # be followed with -H flag.
118 cp -Hrt "$out/lib/erlang/lib/${name}-${version}" "$reldir"
122 # Copy the source so it can be used by dependent packages. For example,
123 # phoenix applications need the source of phoenix and phoenix_html to
124 # build javascript and css assets.
126 cp -r $src/* "$out/src"
131 # stripping does not have any effect on beam files
132 # it is however needed for dependencies with NIFs like bcrypt for example