beamPackages.mixRelease: extract mixReleaseSetupHook

Assisted-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Adam C. Stephens
2026-08-28 13:26:43 -04:00
parent 44323b5dcd
commit ab47a5d584
4 changed files with 28 additions and 18 deletions

View File

@@ -86,6 +86,7 @@ makeScopeWithSplicing' {
mixBuildDirHook
mixCompileHook
mixEscriptSetupHook
mixReleaseSetupHook
rebar3CompileHook
rebarDevendorPatchHook
;

View File

@@ -33,6 +33,11 @@
meta.license = lib.licenses.mit;
} ./mix-escript-setup-hook.sh;
mixReleaseSetupHook = makeSetupHook {
name = "mix-release-setup-hook.sh";
meta.license = lib.licenses.mit;
} ./mix-release-setup-hook.sh;
rebar3CompileHook = makeSetupHook {
name = "rebar3-compile-hook.sh";
meta.license = lib.licenses.mit;

View File

@@ -0,0 +1,17 @@
# shellcheck shell=bash
mixReleaseInstallHook() {
echo "Executing mixReleaseInstallHook"
runHook preInstall
mix release ${mixReleaseName:+"$mixReleaseName"} --no-deps-check --path "$out"
runHook postInstall
echo "Finished mixReleaseInstallHook"
}
if [ -z "${dontMixReleaseInstall-}" ] && [ -z "${installPhase-}" ]; then
installPhase=mixReleaseInstallHook
fi

View File

@@ -17,7 +17,9 @@
gnugrep,
gawk,
mixBuildDirHook,
mixCompileHook,
mixEscriptSetupHook,
mixReleaseSetupHook,
}@inputs:
lib.extendMkDerivation {
@@ -42,6 +44,7 @@ lib.extendMkDerivation {
mixEnv ? "prod",
mixTarget ? "host",
compileFlags ? [ ],
mixCompileFlags ? compileFlags,
# Build a particular named release.
# see https://hexdocs.pm/mix/1.12/Mix.Tasks.Release.html#content
mixReleaseName ? "",
@@ -115,8 +118,10 @@ lib.extendMkDerivation {
ripgrep
mixBuildDirHook
mixCompileHook
]
++ lib.optionals (escriptBinName != null) [ mixEscriptSetupHook ]
++ lib.optionals (escriptBinName == null) [ mixReleaseSetupHook ]
++ (builtins.attrValues mixNixDeps);
buildInputs = [
@@ -208,24 +213,6 @@ lib.extendMkDerivation {
runHook postConfigure
'';
buildPhase =
attrs.buildPhase or ''
runHook preBuild
mix compile --no-deps-check ${lib.concatStringsSep " " compileFlags}
runHook postBuild
'';
installPhase =
attrs.installPhase or ''
runHook preInstall
mix release ${mixReleaseName} --no-deps-check --path "$out"
runHook postInstall
'';
postFixup = ''
echo "removing files for Microsoft Windows"
rm -f "$out"/bin/*.bat