Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions pkgs/development/beam-modules/build-mix.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
erlang,
hex,
beamCopySourceHook,
beamCopySourceToSourceRootHook,
beamModuleInstallHook,
mixBuildDirHook,
mixCompileHook,
Expand Down Expand Up @@ -33,7 +34,12 @@ lib.extendMkDerivation {
# Deterministic Erlang builds remove full system paths from debug information
# among other things to keep builds more reproducible. See their docs for more:
# https://www.erlang.org/doc/man/compile
erlangDeterministicBuilds ? true,
#
# Default to `true` to reduce the closure size
# and prevent `mix` to leave artifacts in `$out/src`
# but be aware that it breaks some apps (eg. those using Surface)
# see https://github.com/surface-ui/surface/issues/762#issuecomment-3577960256
erlangDeterministicBuilds ? finalAttrs.erlangDeterministicBuilds or true,
...
}@args:
{
Expand Down Expand Up @@ -74,7 +80,7 @@ lib.extendMkDerivation {
elixir
hex

beamCopySourceHook
(if erlangDeterministicBuilds then beamCopySourceHook else beamCopySourceToSourceRootHook)
beamModuleInstallHook
mixBuildDirHook
mixCompileHook
Expand Down
1 change: 1 addition & 0 deletions pkgs/development/beam-modules/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ let

inherit (callPackages ./hooks { })
beamCopySourceHook
beamCopySourceToSourceRootHook
beamModuleInstallHook
mixBuildDirHook
mixCompileHook
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# When using some libraries (eg. surface or fine)
# building needs to access files in the build path of dependencies
# as returned by `module_info/1` (which requires `erlangDeterministicBuilds == false`).
# Hence this hook makes the build happen inside `$out/src` instead of /build/source`.
#
# Remark: any `patchPhase` will (correctly) be applied to `$out/src`.
#
beamCopySourceToSourceRootHook() {
echo "Executing beamCopySourceToSourceRootHook"

mkdir -p "$out"
src="$out/src"
cp -r "$sourceRoot" "$src"
sourceRoot="$src"

echo "Finished beamCopySourceToSourceRootHook"
}

postUnpackHooks+=(beamCopySourceToSourceRootHook)
4 changes: 4 additions & 0 deletions pkgs/development/beam-modules/hooks/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
meta.license = lib.licenses.mit;
} ./beam-copy-source-hook.sh;

beamCopySourceToSourceRootHook = makeSetupHook {
name = "beam-copy-source-to-sourceRoot-hook.sh";
} ./beam-copy-source-to-sourceRoot-hook.sh;

beamModuleInstallHook = makeSetupHook {
name = "beam-module-install-hook.sh";
meta.license = lib.licenses.mit;
Expand Down
Loading