10
10
} :
11
11
12
12
let
13
- isGhcjs = ghc . isGhcjs or false ;
13
+ isGhcjs = ghc . isGhcjs or false ;
14
14
ghcCommand' = if isGhcjs then "ghcjs" else "ghc" ;
15
- ghcCommand = "${ ghc . targetPrefix } ${ ghcCommand' } " ;
16
- ghcCommandCaps = lib . toUpper ghcCommand' ;
17
- libDir = "$out/lib/${ ghcCommand } -${ ghc . version } " ;
18
- docDir = "$out/share/doc/ghc/html" ;
19
- packageCfgDir = "${ libDir } /package.conf.d" ;
15
+ ghcCommand = "${ ghc . targetPrefix } ${ ghcCommand' } " ;
16
+ ghcCommandCaps = lib . toUpper ghcCommand' ;
17
+ libDir = "$out/lib/${ ghcCommand } -${ ghc . version } " ;
18
+ docDir = "$out/share/doc/ghc/html" ;
19
+ packageCfgDir = "${ libDir } /package.conf.d" ;
20
20
21
- in runCommand "${ ghc . name } -with -${ package . identifier . name } " {
21
+ in runCommand "${ ghc . name } -for -${ package . identifier . name } " {
22
22
preferLocalBuild = true ;
23
23
passthru = {
24
24
inherit ( ghc ) version meta ;
@@ -32,49 +32,56 @@ in runCommand "${ghc.name}-with-${package.identifier.name}" {
32
32
# Start with a ghc...
33
33
mkdir -p $out/bin
34
34
${ lndir } /bin/lndir -silent ${ ghc } $out
35
-
36
- # ...and replace package database with the one from target package config.
37
- rm -rf ${ libDir }
38
- mkdir -p ${ libDir }
39
- # ... yet retain the lib/.../bin directory. This contains `unlit' and friends.
40
- ${ lndir } /bin/lndir -silent ${ ghc } /lib/${ ghcCommand } -${ ghc . version } /bin ${ libDir }
41
-
35
+ # ... remove all of the package directories
36
+ rm -rf ${ libDir } /*/
37
+ # ... but retain the lib/ghc/bin directory. This contains `unlit' and friends.
38
+ ln -s ${ ghc } /lib/${ ghcCommand } -${ ghc . version } /bin ${ libDir }
39
+ # Replace the package database with the one from target package config.
42
40
ln -s ${ configFiles } /package.conf.d ${ packageCfgDir }
43
41
44
42
# Wrap compiler executables with correct env variables.
45
43
# The NIX_ variables are used by the patched Paths_ghc module.
46
- # The GHC_ENVIRONMENT variable forces ghc to use the build
47
- # dependencies of the component.
48
44
49
- for prg in ${ ghcCommand } ${ ghcCommand } i ${ ghcCommand } -${ ghc . version } ${ ghcCommand } i-${ ghc . version } runghc runhaskell ; do
45
+ for prg in ${ ghcCommand } ${ ghcCommand } i ${ ghcCommand } -${ ghc . version } ${ ghcCommand } i-${ ghc . version } ; do
50
46
if [[ -x "${ ghc } /bin/$prg" ]]; then
51
47
rm -f $out/bin/$prg
52
48
makeWrapper ${ ghc } /bin/$prg $out/bin/$prg \
49
+ --add-flags '"-B$NIX_${ ghcCommandCaps } _LIBDIR"' \
53
50
--set "NIX_${ ghcCommandCaps } " "$out/bin/${ ghcCommand } " \
54
51
--set "NIX_${ ghcCommandCaps } PKG" "$out/bin/${ ghcCommand } -pkg" \
55
52
--set "NIX_${ ghcCommandCaps } _DOCDIR" "${ docDir } " \
56
- --set "NIX_${ ghcCommandCaps } _LIBDIR" "${ libDir } " \
57
- --set "${ ghcCommandCaps } _ENVIRONMENT" "${ configFiles } /ghc-environment"
53
+ --set "NIX_${ ghcCommandCaps } _LIBDIR" "${ libDir } "
58
54
fi
59
55
done
60
56
61
- # Point ghc-pkg to the package database of the component using the
62
- # GHC_PACKAGE_PATH variable.
63
-
64
- for prg in ${ ghcCommand } -pkg ${ ghcCommand } -pkg-${ ghc . version } ; do
57
+ for prg in runghc runhaskell; do
65
58
if [[ -x "${ ghc } /bin/$prg" ]]; then
66
59
rm -f $out/bin/$prg
67
- makeWrapper ${ ghc } /bin/$prg $out/bin/$prg \
68
- --set "${ ghcCommandCaps } _PACKAGE_PATH" "${ configFiles } /package.conf.d"
60
+ makeWrapper ${ ghc } /bin/$prg $out/bin/$prg \
61
+ --add-flags "-f $out/bin/${ ghcCommand } " \
62
+ --set "NIX_${ ghcCommandCaps } " "$out/bin/${ ghcCommand } " \
63
+ --set "NIX_${ ghcCommandCaps } PKG" "$out/bin/${ ghcCommand } -pkg" \
64
+ --set "NIX_${ ghcCommandCaps } _DOCDIR" "${ docDir } " \
65
+ --set "NIX_${ ghcCommandCaps } _LIBDIR" "${ libDir } "
69
66
fi
70
67
done
71
68
72
- # fixme: check if this is needed
73
- # haddock was referring to the base ghc, https://github.com/NixOS/nixpkgs/issues/36976
69
+ # Wrap haddock, if the base GHC provides it.
74
70
if [[ -x "${ ghc } /bin/haddock" ]]; then
75
71
rm -f $out/bin/haddock
76
72
makeWrapper ${ ghc } /bin/haddock $out/bin/haddock \
73
+ --add-flags '"-B$NIX_${ ghcCommandCaps } _LIBDIR"' \
77
74
--set "NIX_${ ghcCommandCaps } _LIBDIR" "${ libDir } "
78
75
fi
76
+
77
+ # Point ghc-pkg to the package database of the component using the
78
+ # --global-package-db flag.
79
+
80
+ for prg in ${ ghcCommand } -pkg ${ ghcCommand } -pkg-${ ghc . version } ; do
81
+ if [[ -x "${ ghc } /bin/$prg" ]]; then
82
+ rm -f $out/bin/$prg
83
+ makeWrapper ${ ghc } /bin/$prg $out/bin/$prg --add-flags "--global-package-db=${ packageCfgDir } "
84
+ fi
85
+ done
79
86
''
80
87
)
0 commit comments