Skip to content

Add ghcWithPackages and ghcWithHoogle to hsPkgs #150

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions builder/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,29 @@ let
inherit packages hoogle;
};

# Same as haskellPackages.shellFor in nixpkgs.
shellFor = haskellLib.weakCallPackage pkgs ./shell-for.nix {
inherit hsPkgs ghcForComponent makeConfigFiles hoogleLocal haskellLib;
inherit (buildPackages) glibcLocales;
};

# Same as haskellPackages.ghcWithPackages and ghcWithHoogle in nixpkgs.
withPackages = {withHoogle}: packages: (shellFor {
name = ghc.name + "-with-packages";
packages = _: [];
additional = packages;
inherit withHoogle;
}).ghc;

in {
# Build a Haskell package from its config.
# TODO: this pkgs is the adjusted pkgs, but pkgs.pkgs is unadjusted
build-package = haskellLib.weakCallPackage pkgs ./hspkg-builder.nix {
inherit haskellLib ghc buildGHC comp-builder;
};

# Same as haskellPackages.shellFor in nixpkgs.
shellFor = haskellLib.weakCallPackage pkgs ./shell-for.nix {
inherit hsPkgs ghcForComponent makeConfigFiles hoogleLocal haskellLib;
inherit (buildPackages) glibcLocales;
};
inherit shellFor;

ghcWithPackages = withPackages { withHoogle = false; };
ghcWithHoogle = withPackages { withHoogle = true; };
}
7 changes: 4 additions & 3 deletions builder/shell-for.nix
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{ lib, stdenv, glibcLocales, pkgconfig, ghcForComponent, makeConfigFiles, hsPkgs, hoogleLocal, haskellLib }:

{ packages, withHoogle ? true, ... } @ args:
{ packages, additional ? _: [], withHoogle ? true, ... } @ args:

let
selected = packages hsPkgs;
additionalSelected = additional hsPkgs;
selectedConfigs = map (p: p.components.all.config) selected;

name = if lib.length selected == 1
Expand All @@ -15,7 +16,7 @@ let
# new-style commands.
packageInputs = lib.filter
(input: lib.all (cfg: input.identifier != cfg.identifier) selected)
(lib.concatMap (cfg: cfg.depends) selectedConfigs);
(lib.concatMap (cfg: cfg.depends) selectedConfigs ++ additionalSelected);

# Add the system libraries and build tools of the selected haskell
# packages to the shell.
Expand Down Expand Up @@ -53,7 +54,7 @@ let
# inherit (hsPkgs) hoogle;
};

mkDrvArgs = builtins.removeAttrs args ["packages" "withHoogle"];
mkDrvArgs = builtins.removeAttrs args ["packages" "additional" "withHoogle"];
in
stdenv.mkDerivation (mkDrvArgs // {
name = mkDrvArgs.name or name;
Expand Down
8 changes: 8 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
This file contains a summary of changes to Haskell.nix and `nix-tools`
that will impact users.

## June 21, 2019
* Add `ghcWithPackages` and `ghcWithHoogle` to hsPkgs ([documentation](https://input-output-hk.github.io/haskell.nix/reference/library/#package-set-functions).
* Benchmark components can now build successfully.
* Reduced the closure bloat of nix-tools, and added closure size limit to CI.
* Added more reference documentation and set up auto-generated
documentation for [Module Options](https://input-output-hk.github.io/haskell.nix/reference/modules/).
* Miscellaneous bug fixes.

## June 7, 2019
* Several additions to the [documentation](https://input-output-hk.github.io/haskell.nix/).
* More information about getting nix-tools, Haskell.nix, pinning.
Expand Down
2 changes: 1 addition & 1 deletion modules/component-driver.nix
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ in
};

config.hsPkgs =
{ inherit (builder) shellFor;
{ inherit (builder) shellFor ghcWithPackages ghcWithHoogle;
buildPackages = buildModules.config.hsPkgs;
} //
lib.mapAttrs
Expand Down
20 changes: 17 additions & 3 deletions test/snapshots/default.nix
Original file line number Diff line number Diff line change
@@ -1,19 +1,33 @@
{ stdenv, haskellPackages }:
{ stdenv, haskellPackages, snapshots }:

with stdenv.lib;

let
env = snapshots."lts-12.21".ghcWithHoogle
(ps: with ps; [ conduit conduit-extra resourcet ]);

in
stdenv.mkDerivation {
name = "shell-for-test";

buildCommand = ''
########################################################################
# test snapshot ghcWithHoogle
# test single component from haskellPackages

printf "checking that the latest LTS snapshot has the lens package...\n" >& 2
test -d ${haskellPackages.lens.components.library}

########################################################################
# test snapshot ghcWithHoogle

printf "checking that the ghcWithPackages env has the package...\n" >& 2
${env}/bin/ghc-pkg list | grep conduit

touch $out
'';

meta.platforms = platforms.all;
}
passthru = {
inherit env;
};
}