Skip to content

Commit 3900ec9

Browse files
committed
Build without GHC environment files, instead using wrappers
Lets development shells work.
1 parent ec22624 commit 3900ec9

File tree

2 files changed

+19
-12
lines changed

2 files changed

+19
-12
lines changed

builder/comp-builder.nix

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,6 @@ stdenv.mkDerivation ({
221221
};
222222

223223
CABAL_CONFIG = configFiles + /cabal.config;
224-
GHC_ENVIRONMENT = configFiles + /ghc-environment;
225224
LANG = "en_US.UTF-8"; # GHC needs the locale configured during the Haddock phase.
226225
LC_ALL = "en_US.UTF-8";
227226

@@ -232,7 +231,7 @@ stdenv.mkDerivation ({
232231
++ component.pkgconfig;
233232

234233
nativeBuildInputs =
235-
[ghc buildPackages.removeReferencesTo]
234+
[shellWrappers buildPackages.removeReferencesTo]
236235
++ lib.optional (component.pkgconfig != []) pkgconfig
237236
++ executableToolDepends;
238237

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)