Skip to content

Commit 08bb11b

Browse files
committed
Fixes for shellFor and hoogle in shell
1 parent d7004ee commit 08bb11b

File tree

8 files changed

+35
-21
lines changed

8 files changed

+35
-21
lines changed

builder/comp-builder.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,7 @@ let
499499
if id=$(${target-pkg-and-db} field "z-${package.identifier.name}-z-*" id --simple-output); then
500500
name=$(${target-pkg-and-db} field "z-${package.identifier.name}-z-*" name --simple-output)
501501
echo "--dependency=''${name#z-${package.identifier.name}-z-}=$id" >> $out/exactDep/configure-flags
502+
echo "package-id $id" >> $out/envDep
502503
''
503504
# Allow `package-name:sublib-name` to work in `build-depends`
504505
# by adding the same `--dependency` again, but with the package

builder/default.nix

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,11 @@ let
4444

4545

4646
hoogleLocal = let
47-
nixpkgsHoogle = import (pkgs.path + /pkgs/development/haskell-modules/hoogle.nix);
47+
# Use hoogle.nix from at least nixpkgs 22.05
48+
nixpkgs = if lib.versionAtLeast lib.trivial.release "22.05"
49+
then pkgs.path
50+
else pkgs.haskell-nix.sources.nixpkgs-2205;
51+
nixpkgsHoogle = import (nixpkgs + /pkgs/development/haskell-modules/hoogle.nix);
4852
in { packages ? [], hoogle ? pkgs.buildPackages.haskell-nix.tool "ghc8107" "hoogle" {
4953
inherit evalPackages;
5054
version = "5.0.18.3";
@@ -59,11 +63,9 @@ let
5963
else ghc;
6064
inherit packages hoogle;
6165
};
62-
in if lib.versionAtLeast lib.trivial.release "22.05"
63-
then haskellLib.weakCallPackage pkgs nixpkgsHoogle {
64-
inherit haskellPackages;
65-
} (p: p.packages)
66-
else haskellLib.weakCallPackage pkgs nixpkgsHoogle haskellPackages;
66+
in haskellLib.weakCallPackage pkgs nixpkgsHoogle {
67+
inherit haskellPackages;
68+
} (p: p.packages);
6769

6870
# Same as haskellPackages.shellFor in nixpkgs.
6971
shellFor = haskellLib.weakCallPackage pkgs ./shell-for.nix {

builder/ghc-for-component-wrapper.nix

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,11 @@ let
149149
passthru = {
150150
inherit (ghc) version meta;
151151
};
152+
propagatedBuildInputs = configFiles.libDeps;
152153
nativeBuildInputs = [ghc];
153154
} (''
154-
configFiles=$(mktemp -d)
155+
mkdir -p $out/configFiles
156+
configFiles=$out/configFiles
155157
${configFiles.script}
156158
wrappedGhc=$out
157159
${script}

builder/haddock-builder.nix

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ let
4747
finalConfigureFlags = lib.concatStringsSep " " (
4848
[ "--prefix=${componentDrv}"
4949
"${haskellLib.componentTarget componentId}"
50-
"$(cat ${docsConfigFiles}/configure-flags)"
50+
"$(cat $configFiles/configure-flags)"
5151
]
5252
++ commonConfigureFlags
5353
++ lib.optional doHaddock' " --docdir=${docdir "$doc"}");
@@ -66,7 +66,7 @@ let
6666
configFiles = docsConfigFiles;
6767

6868
# The directory containing the haddock documentation.
69-
haddockDir = if doHaddock' then "${docdir drv.doc}/html" else null;
69+
haddockDir = lib.const (if doHaddock' then "${docdir drv.doc}/html" else null);
7070
};
7171

7272
# `out` contains the `package.conf.d` files used for building the
@@ -75,16 +75,22 @@ let
7575
outputs = ["out"]
7676
++ lib.optional doHaddock' "doc";
7777

78-
propagatedBuildInputs = builtins.concatLists pkgconfig;
78+
propagatedBuildInputs =
79+
builtins.concatLists pkgconfig
80+
++ configFiles.libDeps;
7981

80-
buildInputs = component.libs
81-
++ map (d: d.components.library.haddock or d) component.depends;
82+
buildInputs = component.libs;
8283

8384
nativeBuildInputs =
84-
[ shellWrappers buildPackages.removeReferencesTo ]
85+
[ ghc buildPackages.removeReferencesTo ]
8586
++ componentDrv.executableToolDepends;
8687

8788
configurePhase = ''
89+
configFiles=$(mktemp -d)
90+
${docsConfigFiles.script}
91+
wrappedGhc=$(mktemp -d)
92+
${shellWrappers.script}
93+
PATH=$wrappedGhc/bin:$PATH
8894
runHook preConfigure
8995
echo Configure flags:
9096
printf "%q " ${finalConfigureFlags}
@@ -145,7 +151,7 @@ let
145151
# working hyper links.
146152
pkg=$(basename "$i")
147153
sed -e "s|haddock-interfaces:.*|haddock-interfaces: $docdir/html/${componentId.cname}.haddock|" -e "s|haddock-html:.*|haddock-html: $docdir/html/|" "$i" > "$pkg"
148-
${ghc.targetPrefix}ghc-pkg -v0 --package-db ${docsConfigFiles}/${configFiles.packageCfgDir} -f $out/package.conf.d register "$pkg"
154+
${ghc.targetPrefix}ghc-pkg -v0 --package-db $configFiles/${configFiles.packageCfgDir} -f $out/package.conf.d register "$pkg"
149155
done
150156
151157
ln -s ${componentDrv}/exactDep $out/exactDep

builder/hspkg-builder.nix

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,17 @@ let
4141

4242
setup = if package.buildType == "Simple"
4343
then ghc.defaultSetupFor package.identifier.name
44-
else setup-builder {
44+
else setup-builder ({
4545
component = components.setup // {
4646
depends = config.setup-depends ++ components.setup.depends ++ package.setup-depends;
4747
extraSrcFiles = components.setup.extraSrcFiles ++ [ "Setup.hs" "Setup.lhs" ];
4848
pkgconfig = if components ? library then components.library.pkgconfig or [] else [];
4949
};
5050
inherit package name src flags revision patches defaultSetupSrc;
5151
inherit (pkg) preUnpack postUnpack;
52-
};
52+
} // lib.optionalAttrs (package.buildType != "Custom") {
53+
nonReinstallablePkgs = ["base" "Cabal"];
54+
});
5355

5456
buildComp = allComponent: componentId: component: comp-builder {
5557
inherit allComponent componentId component package name src flags setup cabalFile cabal-generator patches revision

builder/make-config-files.nix

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ let
128128
echo "allow-older: ${identifier.name}:*" >> $configFiles/cabal.config
129129
''}
130130
131-
for p in $propagatedBuildInputs; do
131+
for p in "''${pkgsHostTarget[@]}"; do
132132
if [ -e $p/envDep ]; then
133133
cat $p/envDep >> $configFiles/ghc-environment
134134
fi
@@ -203,6 +203,7 @@ let
203203
'';
204204
drv = runCommand "${ghc.targetPrefix}${fullName}-config" {
205205
nativeBuildInputs = [ghc];
206+
propagatedBuildInputs = libDeps;
206207
} (''
207208
mkdir -p $out
208209
configFiles=$out

builder/setup-builder.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ let
8282
if [ -f $f ]; then
8383
echo Compiling package $f
8484
ghc $f -threaded ${if includeGhcPackage then "-package ghc " else ""
85-
}-package-db $configFiles/${configFiles.packageCfgDir} --make -o ./Setup
85+
}-package-env $configFiles/ghc-environment --make -o ./Setup
8686
fi
8787
done
8888
[ -f ./Setup ] || (echo Failed to build Setup && exit 1)

builder/shell-for.nix

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ let
124124
# hoogle.nix expects.
125125
docPackage = p: lib.getOutput "doc" p // {
126126
pname = p.identifier.name;
127-
haddockDir = lib.const p.haddockDir;
127+
haddockDir = p.haddockDir;
128128
};
129129
in hoogleLocal ({
130130
packages = map docPackage (haskellLib.flatLibDepends component);
@@ -149,7 +149,7 @@ in
149149

150150
buildInputs = systemInputs
151151
++ mkDrvArgs.buildInputs or [];
152-
nativeBuildInputs = [ ghcEnv ]
152+
nativeBuildInputs = [ ghcEnv.drv ]
153153
++ nativeBuildInputs
154154
++ mkDrvArgs.nativeBuildInputs or []
155155
++ lib.attrValues (buildPackages.haskell-nix.tools' evalPackages compiler.nix-name tools)
@@ -178,7 +178,7 @@ in
178178

179179
# This helps tools like `ghcide` (that use the ghc api) to find
180180
# the correct global package DB.
181-
NIX_GHC_LIBDIR = ghcEnv + "/" + configFiles.libDir;
181+
NIX_GHC_LIBDIR = ghcEnv.drv + "/" + configFiles.libDir;
182182

183183
passthru = (mkDrvArgs.passthru or {}) // {
184184
ghc = ghcEnv;

0 commit comments

Comments
 (0)