Skip to content

Commit 5388894

Browse files
committed
Rename withPackage to ghcForComponent
1 parent 1e5f356 commit 5388894

File tree

4 files changed

+19
-15
lines changed

4 files changed

+19
-15
lines changed

builder/comp-builder.nix

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{ stdenv, buildPackages, ghc, lib, pkgconfig, writeText, runCommand, haskellLib, nonReinstallablePkgs, withPackage, hsPkgs }:
1+
{ stdenv, buildPackages, ghc, lib, pkgconfig, writeText, runCommand, haskellLib, nonReinstallablePkgs, ghcForComponent, hsPkgs }:
22

33
{ componentId
44
, component
@@ -181,8 +181,9 @@ let
181181

182182
# Unfortunately, we need to wrap ghc commands for cabal builds to
183183
# work in the nix-shell. See ../doc/removing-with-package-wrapper.md.
184-
shellWrappers = withPackage {
185-
inherit package configFiles;
184+
shellWrappers = ghcForComponent {
185+
componentName = fullName;
186+
inherit configFiles;
186187
};
187188

188189
# the target dir for haddock documentation

builder/default.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{ pkgs, buildPackages, stdenv, lib, haskellLib, ghc, buildGHC, fetchurl, writeText, runCommand, pkgconfig, nonReinstallablePkgs, withPackage, hsPkgs }:
1+
{ pkgs, buildPackages, stdenv, lib, haskellLib, ghc, buildGHC, fetchurl, writeText, runCommand, pkgconfig, nonReinstallablePkgs, ghcForComponent, hsPkgs }:
22

33
{ flags
44
, package
@@ -72,7 +72,7 @@ let
7272
'';
7373
};
7474

75-
comp-builder = haskellLib.weakCallPackage pkgs ./comp-builder.nix { inherit ghc haskellLib nonReinstallablePkgs withPackage hsPkgs; };
75+
comp-builder = haskellLib.weakCallPackage pkgs ./comp-builder.nix { inherit ghc haskellLib nonReinstallablePkgs ghcForComponent hsPkgs; };
7676

7777
buildComp = componentId: component: comp-builder {
7878
inherit componentId component package name src flags setup cabalFile cabal-generator patches revision

builder/with-package-wrapper.nix renamed to builder/ghc-for-component-wrapper.nix

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1-
# This is a simplified version of the ghcWithPackages wrapper in
2-
# nixpkgs, adapted to work with the package database of a single
3-
# component.
1+
# The ghcForComponent function wraps ghc so that it is configured with
2+
# the package database of all dependencies of a given component.
3+
# It has been adapted from the ghcWithPackages wrapper in nixpkgs.
4+
#
5+
# This wrapper exists so that nix-shells for components will have a
6+
# GHC automatically configured with the dependencies in the package
7+
# database.
8+
49
{ lib, stdenv, ghc, runCommand, lndir, makeWrapper
510
}:
611

7-
{ package
8-
, configFiles
9-
, postBuild ? ""
12+
{ componentName # Full derivation name of the component
13+
, configFiles # The component's "config" derivation
1014
}:
1115

1216
let
@@ -18,12 +22,11 @@ let
1822
docDir = "$out/share/doc/ghc/html";
1923
packageCfgDir = "${libDir}/package.conf.d";
2024

21-
in runCommand "${ghc.name}-for-${package.identifier.name}" {
25+
in runCommand "${componentName}-${ghc.name}" {
2226
preferLocalBuild = true;
2327
passthru = {
2428
inherit (ghc) version meta;
2529
baseGhc = ghc;
26-
inherit package;
2730
};
2831
} (
2932
''

modules/component-driver.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ let
66
ghc = config.ghc.package;
77
buildGHC = buildModules.config.ghc.package;
88
inherit (config) nonReinstallablePkgs hsPkgs;
9-
inherit withPackage;
9+
inherit ghcForComponent;
1010
};
1111

12-
withPackage = import ../builder/with-package-wrapper.nix {
12+
ghcForComponent = import ../builder/ghc-for-component-wrapper.nix {
1313
inherit lib;
1414
inherit (pkgs.buildPackages) stdenv runCommand makeWrapper;
1515
inherit (pkgs.buildPackages.xorg) lndir;

0 commit comments

Comments
 (0)