on iko/ghcjs-patch-master help sign in
Add ghcWithPackages and ghcWithHoogle to hsPkgs (#150)

* Add ghcWithPackages and ghcWithHoogle to hsPkgs * tests: Add ghcWithHoogle test * Update changelog

commit0663a9cd036bb4d94f10b93e82d65f86cfb616b6 authorRodney Lorrimar <rodney.lorrimar@iohk.io> dateFri 21 Jun 2019, 22:40 (7 years ago) parent5ac12d0
5 files changed+48−12
builder/default.nix+18−5 builder/shell-for.nix+4−3 changelog.md+8 modules/component-driver.nix+1−1 test/snapshots/default.nix+17−3
builder/default.nix+18−5
@@ -27,6 +27,20 @@ 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+
3044in {
3145 # Build a Haskell package from its config.
3246 # TODO: this pkgs is the adjusted pkgs, but pkgs.pkgs is unadjusted
@@ -34,9 +48,8 @@ in {
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+4−3
@@ -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
55let
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"];
5758in
5859 stdenv.mkDerivation (mkDrvArgs // {
5960 name = mkDrvArgs.name or name;
changelog.md+8
@@ -1,6 +1,14 @@
11This file contains a summary of changes to Haskell.nix and `nix-tools`
22that 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+1−1
@@ -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+17−3
@@ -1,19 +1,33 @@
1−{ stdenv, haskellPackages }:
1+{ stdenv, haskellPackages, snapshots }:
22
33with 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+}