Skip to content

Commit 3454081

Browse files
committed
Build without GHC environment files, instead using wrappers
Lets development shells work.
1 parent 5180ae9 commit 3454081

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed

builder/comp-builder.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ stdenv.mkDerivation ({
218218
};
219219

220220
CABAL_CONFIG = configFiles + /cabal.config;
221-
GHC_ENVIRONMENT = configFiles + /ghc-environment;
221+
# GHC_ENVIRONMENT = configFiles + /ghc-environment;
222222
LANG = "en_US.UTF-8"; # GHC needs the locale configured during the Haddock phase.
223223
LC_ALL = "en_US.UTF-8";
224224

@@ -229,7 +229,7 @@ stdenv.mkDerivation ({
229229
++ component.pkgconfig;
230230

231231
nativeBuildInputs =
232-
[ghc buildPackages.removeReferencesTo]
232+
[shellWrappers buildPackages.removeReferencesTo]
233233
++ lib.optional (component.pkgconfig != []) pkgconfig
234234
++ executableToolDepends;
235235

builder/with-package-wrapper.nix

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,35 +34,43 @@ in runCommand "${ghc.name}-with-${package.identifier.name}" {
3434
${lndir}/bin/lndir -silent ${ghc} $out
3535
3636
# ...and replace package database with the one from target package config.
37-
rm -rf ${libDir}
38-
mkdir -p ${libDir}
37+
rm -rf ${libDir}/*/
3938
ln -s ${configFiles}/package.conf.d ${packageCfgDir}
4039
4140
# Wrap compiler executables with correct env variables.
4241
# The NIX_ variables are used by the patched Paths_ghc module.
43-
# The GHC_ENVIRONMENT variable forces ghc to use the build
44-
# dependencies of the component.
4542
46-
for prg in ${ghcCommand} ${ghcCommand}i ${ghcCommand}-${ghc.version} ${ghcCommand}i-${ghc.version} runghc runhaskell; do
43+
for prg in ${ghcCommand} ${ghcCommand}i ${ghcCommand}-${ghc.version} ${ghcCommand}i-${ghc.version}; do
4744
if [[ -x "${ghc}/bin/$prg" ]]; then
4845
rm -f $out/bin/$prg
4946
makeWrapper ${ghc}/bin/$prg $out/bin/$prg \
47+
--add-flags '"-B$NIX_${ghcCommandCaps}_LIBDIR"' \
5048
--set "NIX_${ghcCommandCaps}" "$out/bin/${ghcCommand}" \
5149
--set "NIX_${ghcCommandCaps}PKG" "$out/bin/${ghcCommand}-pkg" \
5250
--set "NIX_${ghcCommandCaps}_DOCDIR" "${docDir}" \
53-
--set "NIX_${ghcCommandCaps}_LIBDIR" "${libDir}" \
54-
--set "${ghcCommandCaps}_ENVIRONMENT" "${configFiles}/ghc-environment"
51+
--set "NIX_${ghcCommandCaps}_LIBDIR" "${libDir}"
52+
fi
53+
done
54+
55+
for prg in runghc runhaskell; do
56+
if [[ -x "${ghc}/bin/$prg" ]]; then
57+
rm -f $out/bin/$prg
58+
makeWrapper ${ghc}/bin/$prg $out/bin/$prg \
59+
--add-flags "-f $out/bin/${ghcCommand}" \
60+
--set "NIX_${ghcCommandCaps}" "$out/bin/${ghcCommand}" \
61+
--set "NIX_${ghcCommandCaps}PKG" "$out/bin/${ghcCommand}-pkg" \
62+
--set "NIX_${ghcCommandCaps}_DOCDIR" "${docDir}" \
63+
--set "NIX_${ghcCommandCaps}_LIBDIR" "${libDir}"
5564
fi
5665
done
5766
5867
# Point ghc-pkg to the package database of the component using the
59-
# GHC_PACKAGE_PATH variable.
68+
# --global-package-db flag.
6069
6170
for prg in ${ghcCommand}-pkg ${ghcCommand}-pkg-${ghc.version}; do
6271
if [[ -x "${ghc}/bin/$prg" ]]; then
6372
rm -f $out/bin/$prg
64-
makeWrapper ${ghc}/bin/$prg $out/bin/$prg \
65-
--set "${ghcCommandCaps}_PACKAGE_PATH" "${configFiles}/package.conf.d"
73+
makeWrapper ${ghc}/bin/$prg $out/bin/$prg --add-flags "--global-package-db=${packageCfgDir}"
6674
fi
6775
done
6876

0 commit comments

Comments
 (0)