Skip to content

Commit 0663a9c

Browse files
authored
Add ghcWithPackages and ghcWithHoogle to hsPkgs (#150)
* Add ghcWithPackages and ghcWithHoogle to hsPkgs * tests: Add ghcWithHoogle test * Update changelog
1 parent 5ac12d0 commit 0663a9c

File tree

5 files changed

+48
-12
lines changed

5 files changed

+48
-12
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+
}).ghc;
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: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
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
@@ -15,7 +16,7 @@ let
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;

changelog.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
This file contains a summary of changes to Haskell.nix and `nix-tools`
22
that will impact users.
33

4+
## June 21, 2019
5+
* Add `ghcWithPackages` and `ghcWithHoogle` to hsPkgs ([documentation](https://input-output-hk.github.io/haskell.nix/reference/library/#package-set-functions).
6+
* Benchmark components can now build successfully.
7+
* Reduced the closure bloat of nix-tools, and added closure size limit to CI.
8+
* Added more reference documentation and set up auto-generated
9+
documentation for [Module Options](https://input-output-hk.github.io/haskell.nix/reference/modules/).
10+
* Miscellaneous bug fixes.
11+
412
## June 7, 2019
513
* Several additions to the [documentation](https://input-output-hk.github.io/haskell.nix/).
614
* More information about getting nix-tools, Haskell.nix, pinning.

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

test/snapshots/default.nix

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,33 @@
1-
{ stdenv, haskellPackages }:
1+
{ stdenv, haskellPackages, snapshots }:
22

33
with stdenv.lib;
44

5+
let
6+
env = snapshots."lts-12.21".ghcWithHoogle
7+
(ps: with ps; [ conduit conduit-extra resourcet ]);
8+
9+
in
510
stdenv.mkDerivation {
611
name = "shell-for-test";
712

813
buildCommand = ''
914
########################################################################
10-
# test snapshot ghcWithHoogle
15+
# test single component from haskellPackages
1116
1217
printf "checking that the latest LTS snapshot has the lens package...\n" >& 2
1318
test -d ${haskellPackages.lens.components.library}
1419
20+
########################################################################
21+
# test snapshot ghcWithHoogle
22+
23+
printf "checking that the ghcWithPackages env has the package...\n" >& 2
24+
${env}/bin/ghc-pkg list | grep conduit
25+
1526
touch $out
1627
'';
1728

1829
meta.platforms = platforms.all;
19-
}
30+
passthru = {
31+
inherit env;
32+
};
33+
}

0 commit comments

Comments
 (0)