Skip to content

Commit 77ea18a

Browse files
committed
Add ghcWithPackages and ghcWithHoogle to hsPkgs
1 parent 5576a98 commit 77ea18a

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
@@ -20,16 +20,29 @@ let
2020
inherit ghc haskellLib nonReinstallablePkgs;
2121
};
2222

23+
# Same as haskellPackages.shellFor in nixpkgs.
24+
shellFor = haskellLib.weakCallPackage pkgs ./shell-for.nix {
25+
inherit hsPkgs ghcForComponent makeConfigFiles;
26+
inherit (buildPackages) glibcLocales;
27+
};
28+
29+
# Same as haskellPackages.ghcWithPackages and ghcWithHoogle in nixpkgs.
30+
withPackages = {withHoogle}: packages: shellFor {
31+
name = ghc.name + "-with-packages";
32+
packages = _: [];
33+
additional = packages;
34+
inherit withHoogle;
35+
};
36+
2337
in {
2438
# Build a Haskell package from its config.
2539
# TODO: this pkgs is the adjusted pkgs, but pkgs.pkgs is unadjusted
2640
build-package = haskellLib.weakCallPackage pkgs ./hspkg-builder.nix {
2741
inherit haskellLib ghc buildGHC comp-builder;
2842
};
2943

30-
# Same as haskellPackages.shellFor in nixpkgs.
31-
shellFor = haskellLib.weakCallPackage pkgs ./shell-for.nix {
32-
inherit hsPkgs ghcForComponent makeConfigFiles;
33-
inherit (buildPackages) glibcLocales;
34-
};
44+
inherit shellFor;
45+
46+
ghcWithPackages = withPackages { withHoogle = false; };
47+
ghcWithHoogle = withPackages { withHoogle = true; };
3548
}

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 }:
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.
@@ -37,7 +38,7 @@ let
3738
componentName = name;
3839
inherit configFiles;
3940
};
40-
mkDrvArgs = builtins.removeAttrs args ["packages" "withHoogle"];
41+
mkDrvArgs = builtins.removeAttrs args ["packages" "additional" "withHoogle"];
4142
in
4243
stdenv.mkDerivation (mkDrvArgs // {
4344
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)