generic-stack-builder: also support nix-build
We need to add the STACK_IN_NIX_EXTRA_ARGS hook in configurePhase also to ensure we get the right args when calling ```nix-build``` (as opposed to nix-shell).
This commit is contained in:
parent
12ee278a0d
commit
1682353805
@ -11,6 +11,18 @@ with stdenv.lib;
|
||||
}@args:
|
||||
|
||||
let stackCmd = "stack --internal-re-exec-version=${stack.version}";
|
||||
|
||||
# Add all dependencies in buildInputs including propagated ones to
|
||||
# STACK_IN_NIX_EXTRA_ARGS.
|
||||
addStackArgsHook = ''
|
||||
for pkg in ''${pkgsHostHost[@]} ''${pkgsHostBuild[@]} ''${pkgsHostTarget[@]}
|
||||
do
|
||||
[ -d "$pkg/lib" ] && \
|
||||
export STACK_IN_NIX_EXTRA_ARGS+=" --extra-lib-dirs=$pkg/lib"
|
||||
[ -d "$pkg/include" ] && \
|
||||
export STACK_IN_NIX_EXTRA_ARGS+=" --extra-include-dirs=$pkg/include"
|
||||
done
|
||||
'';
|
||||
in stdenv.mkDerivation (args // {
|
||||
|
||||
buildInputs =
|
||||
@ -21,15 +33,7 @@ in stdenv.mkDerivation (args // {
|
||||
STACK_PLATFORM_VARIANT="nix";
|
||||
STACK_IN_NIX_SHELL=1;
|
||||
STACK_IN_NIX_EXTRA_ARGS = extraArgs;
|
||||
shellHook = ''
|
||||
for pkg in ''${pkgsHostHost[@]} ''${pkgsHostBuild[@]} ''${pkgsHostTarget[@]}
|
||||
do
|
||||
[ -d "$pkg/lib" ] && \
|
||||
export STACK_IN_NIX_EXTRA_ARGS+=" --extra-lib-dirs=$pkg/lib"
|
||||
[ -d "$pkg/include" ] && \
|
||||
export STACK_IN_NIX_EXTRA_ARGS+=" --extra-include-dirs=$pkg/include"
|
||||
done
|
||||
'';
|
||||
shellHook = addStackArgsHook;
|
||||
|
||||
|
||||
# XXX: workaround for https://ghc.haskell.org/trac/ghc/ticket/11042.
|
||||
@ -46,6 +50,7 @@ in stdenv.mkDerivation (args // {
|
||||
|
||||
configurePhase = args.configurePhase or ''
|
||||
export STACK_ROOT=$NIX_BUILD_TOP/.stack
|
||||
${addStackArgsHook}
|
||||
'';
|
||||
|
||||
buildPhase = args.buildPhase or "${stackCmd} build";
|
||||
|
Loading…
Reference in New Issue
Block a user