Skip to content

Commit c7f3843

Browse files
authored
Merge pull request #130 from input-output-hk/shell-for-plus
Shell for plus
2 parents 45b0db2 + 7cd0715 commit c7f3843

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

builder/make-config-files.nix

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
{ stdenv, lib, haskellLib, ghc, nonReinstallablePkgs, runCommand }:
22

3+
with builtins; with lib;
34
let
45
flagsAndConfig = field: xs: lib.optionalString (xs != []) ''
56
echo ${lib.concatStringsSep " " (map (x: "--${field}=${x}") xs)} >> $out/configure-flags
67
echo "${field}: ${lib.concatStringsSep " " xs}" >> $out/cabal.config
78
'';
89

9-
flatDepends = component:
10+
## packageHasLib :: Package -> Bool
11+
packageHasLib = p: hasAttr "library" p.components;
12+
## flatLibDepends :: Component -> [Package]
13+
flatLibDepends =
14+
component:
1015
let
11-
makePairs = map (p: rec { key="${val}"; val=(p.components.library or p); });
16+
makePairs = map (p: rec { key="${val.name}"; val=p.components.library; });
1217
closure = builtins.genericClosure {
13-
startSet = makePairs component.depends;
18+
startSet = makePairs (filter packageHasLib component.depends);
1419
operator = {val,...}: makePairs val.config.depends;
1520
};
1621
in map ({val,...}: val) closure;
@@ -58,7 +63,7 @@ in { identifier, component, fullName, flags ? {} }:
5863
5964
${lib.concatMapStringsSep "\n" (p: ''
6065
target-pkg --package-db ${p}/package.conf.d dump | target-pkg --force --package-db $out/package.conf.d register -
61-
'') (flatDepends component)}
66+
'') (flatLibDepends component)}
6267
6368
# Note: we pass `clear` first to ensure that we never consult the implicit global package db.
6469
${flagsAndConfig "package-db" ["clear" "$out/package.conf.d"]}
@@ -69,15 +74,17 @@ in { identifier, component, fullName, flags ? {} }:
6974
cat > $out/ghc-environment <<EOF
7075
package-db $out/package.conf.d
7176
EOF
72-
${lib.concatMapStringsSep "\n" (p: envDep "--package-db ${p.components.library or p}/package.conf.d" p.identifier.name) component.depends}
77+
${lib.concatMapStringsSep "\n" (p: envDep "--package-db ${p.components.library}/package.conf.d" p.identifier.name)
78+
(filter packageHasLib component.depends)}
7379
${lib.concatMapStringsSep "\n" (envDep "") (lib.remove "ghc" nonReinstallablePkgs)}
7480
7581
'' + lib.optionalString component.doExactConfig ''
7682
echo "--exact-configuration" >> $out/configure-flags
7783
echo "allow-newer: ${identifier.name}:*" >> $out/cabal.config
7884
echo "allow-older: ${identifier.name}:*" >> $out/cabal.config
7985
80-
${lib.concatMapStringsSep "\n" (p: exactDep "--package-db ${p.components.library}/package.conf.d" p.identifier.name) component.depends}
86+
${lib.concatMapStringsSep "\n" (p: exactDep "--package-db ${p.components.library}/package.conf.d" p.identifier.name)
87+
(filter packageHasLib component.depends)}
8188
${lib.concatMapStringsSep "\n" (exactDep "") nonReinstallablePkgs}
8289
8390
''

builder/shell-for.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{ buildPackages, lib, stdenv, ghcForComponent, makeConfigFiles, hsPkgs }:
22

3-
{ packages, withHoogle ? true } @ args:
3+
{ packages, buildInputs ? [], withHoogle ? true } @ args:
44

55
let
66
selected = packages hsPkgs;
@@ -29,7 +29,7 @@ in
2929
stdenv.mkDerivation (mkDrvArgs // {
3030
name = mkDrvArgs.name or name;
3131

32-
buildInputs = systemInputs ++ mkDrvArgs.buildInputs or [];
32+
buildInputs = buildInputs ++ systemInputs ++ mkDrvArgs.buildInputs or [];
3333
nativeBuildInputs = [ ghcEnv ] ++ nativeBuildInputs ++ mkDrvArgs.nativeBuildInputs or [];
3434
phases = ["installPhase"];
3535
installPhase = "echo $nativeBuildInputs $buildInputs > $out";

0 commit comments

Comments
 (0)