Skip to content

Commit 6a53a2e

Browse files
committed
Add ghcWithPackages and ghcWithHoogle to hsPkgs
1 parent 2a88f7d commit 6a53a2e

File tree

3 files changed

+24
-10
lines changed

3 files changed

+24
-10
lines changed

builder/default.nix

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,29 @@ let
2727
inherit packages hoogle;
2828
};
2929

30+
# Same as haskellPackages.shellFor in nixpkgs.
31+
shellFor = haskellLib.weakCallPackage pkgs ./shell-for.nix {
32+
inherit hsPkgs ghcForComponent makeConfigFiles hoogleLocal haskellLib;
33+
inherit (buildPackages) glibcLocales;
34+
};
35+
36+
# Same as haskellPackages.ghcWithPackages and ghcWithHoogle in nixpkgs.
37+
withPackages = {withHoogle}: packages: shellFor {
38+
name = ghc.name + "-with-packages";
39+
packages = _: [];
40+
additional = packages;
41+
inherit withHoogle;
42+
};
43+
3044
in {
3145
# Build a Haskell package from its config.
3246
# TODO: this pkgs is the adjusted pkgs, but pkgs.pkgs is unadjusted
3347
build-package = haskellLib.weakCallPackage pkgs ./hspkg-builder.nix {
3448
inherit haskellLib ghc buildGHC comp-builder;
3549
};
3650

37-
# Same as haskellPackages.shellFor in nixpkgs.
38-
shellFor = haskellLib.weakCallPackage pkgs ./shell-for.nix {
39-
inherit hsPkgs ghcForComponent makeConfigFiles hoogleLocal haskellLib;
40-
inherit (buildPackages) glibcLocales;
41-
};
51+
inherit shellFor;
52+
53+
ghcWithPackages = withPackages { withHoogle = false; };
54+
ghcWithHoogle = withPackages { withHoogle = true; };
4255
}

builder/shell-for.nix

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
{ lib, stdenv, glibcLocales, pkgconfig, ghcForComponent, makeConfigFiles, hsPkgs, hoogleLocal, haskellLib }:
22

3-
{ packages, withHoogle ? true, ... } @ args:
3+
{ packages, additional ? _: [], withHoogle ? true, ... } @ args:
44

55
let
66
selected = packages hsPkgs;
7+
additionalSelected = additional hsPkgs;
78
selectedConfigs = map (p: p.components.all.config) selected;
89

910
name = if lib.length selected == 1
10-
then "ghc-shell-for-${(lib.head selected).name}"
11+
then "ghc-shell-for-${(lib.head selected).identifier.name}"
1112
else "ghc-shell-for-packages";
1213

1314
# If `packages = [ a b ]` and `a` depends on `b`, don't build `b`,
1415
# because cabal will end up ignoring that built version, assuming
1516
# new-style commands.
1617
packageInputs = lib.filter
1718
(input: lib.all (cfg: input.identifier != cfg.identifier) selected)
18-
(lib.concatMap (cfg: cfg.depends) selectedConfigs);
19+
(lib.concatMap (cfg: cfg.depends) selectedConfigs ++ additionalSelected);
1920

2021
# Add the system libraries and build tools of the selected haskell
2122
# packages to the shell.
@@ -53,7 +54,7 @@ let
5354
# inherit (hsPkgs) hoogle;
5455
};
5556

56-
mkDrvArgs = builtins.removeAttrs args ["packages" "withHoogle"];
57+
mkDrvArgs = builtins.removeAttrs args ["packages" "additional" "withHoogle"];
5758
in
5859
stdenv.mkDerivation (mkDrvArgs // {
5960
name = mkDrvArgs.name or name;

modules/component-driver.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ in
4141
};
4242

4343
config.hsPkgs =
44-
{ inherit (builder) shellFor;
44+
{ inherit (builder) shellFor ghcWithPackages ghcWithHoogle;
4545
buildPackages = buildModules.config.hsPkgs;
4646
} //
4747
lib.mapAttrs

0 commit comments

Comments
 (0)