Skip to content

Commit 458a058

Browse files
committed
Add prebuilt-depends for proprietary dependencies.
1 parent 05a2def commit 458a058

File tree

7 files changed

+43
-15
lines changed

7 files changed

+43
-15
lines changed

builder/comp-builder.nix

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@
9090
# LLVM
9191
, useLLVM ? ghc.useLLVM or false
9292
, smallAddressSpace ? false
93+
94+
, prebuilt-depends ? []
9395
}:
9496
# makeOverridable is called here after all the `? DEFAULT` arguments
9597
# will have been applied. This makes sure that `c.override (oldAttrs: {...})`
@@ -160,6 +162,7 @@ let self =
160162
, enableTSanRTS
161163
, useLLVM
162164
, smallAddressSpace
165+
, prebuilt-depends
163166
}@drvArgs:
164167

165168
let
@@ -213,7 +216,7 @@ let
213216
configFiles = makeConfigFiles {
214217
component = componentForSetup;
215218
inherit (package) identifier;
216-
inherit fullName flags needsProfiling enableDWARF;
219+
inherit fullName flags needsProfiling enableDWARF prebuilt-depends;
217220
};
218221

219222
enableFeature = enable: feature:
@@ -852,5 +855,6 @@ in drv; in self) {
852855
enableDWARF
853856
enableTSanRTS
854857
useLLVM
855-
smallAddressSpace;
858+
smallAddressSpace
859+
prebuilt-depends;
856860
}

builder/hspkg-builder.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ let
5858
inherit allComponent componentId component package name src flags setup cabalFile cabal-generator patches
5959
shellHook
6060
;
61+
inherit (config) prebuilt-depends;
6162
};
6263

6364
in rec {

builder/make-config-files.nix

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

3-
{ identifier, component, fullName, flags ? {}, needsProfiling ? false, enableDWARF ? false, chooseDrv ? drv: drv, nonReinstallablePkgs ? defaults.nonReinstallablePkgs }:
3+
{ identifier, component, fullName, flags ? {}, needsProfiling ? false, enableDWARF ? false, chooseDrv ? drv: drv, nonReinstallablePkgs ? defaults.nonReinstallablePkgs, prebuilt-depends ? [] }:
44

55
let
66
# Sort and remove duplicates from nonReinstallablePkgs.
@@ -57,7 +57,7 @@ let
5757
((if needsProfiling then (x: map (p: p.profiled or p) x) else x: x)
5858
(map haskellLib.dependToLib component.depends))
5959
)
60-
);
60+
) ++ prebuilt-depends;
6161
script = ''
6262
${target-pkg} init $configFiles/${packageCfgDir}
6363
@@ -149,17 +149,6 @@ let
149149
echo "allow-older: ${identifier.name}:*" >> $configFiles/cabal.config
150150
''}
151151
152-
for p in "''${pkgsHostTarget[@]}"; do
153-
if [ -e $p/envDep ]; then
154-
cat $p/envDep >> $configFiles/ghc-environment
155-
fi
156-
${ lib.optionalString component.doExactConfig ''
157-
if [ -d $p/exactDep ]; then
158-
cat $p/exactDep/configure-flags >> $configFiles/configure-flags
159-
cat $p/exactDep/cabal.config >> $configFiles/cabal.config
160-
fi
161-
''}
162-
done
163152
for p in ${lib.concatStringsSep " " nonReinstallablePkgs'}; do
164153
if [ -e $ghcDeps/envDeps/$p ]; then
165154
cat $ghcDeps/envDeps/$p >> $configFiles/ghc-environment
@@ -172,6 +161,18 @@ let
172161
cat $ghcDeps/exactDeps/$p/cabal.config >> $configFiles/cabal.config
173162
fi
174163
done
164+
'' + ''
165+
for p in "''${pkgsHostTarget[@]}"; do
166+
if [ -e $p/envDep ]; then
167+
cat $p/envDep >> $configFiles/ghc-environment
168+
fi
169+
${ lib.optionalString component.doExactConfig ''
170+
if [ -d $p/exactDep ]; then
171+
cat $p/exactDep/configure-flags >> $configFiles/configure-flags
172+
cat $p/exactDep/cabal.config >> $configFiles/cabal.config
173+
fi
174+
''}
175+
done
175176
''
176177
# This code originates in the `generic-builder.nix` from nixpkgs. However GHC has been fixed
177178
# to drop unused libraries referenced from libraries; and this patch is usually included in the

lib/call-cabal-project-to-nix.nix

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
, evalPackages
6363
, supportHpack ? false # Run hpack on package.yaml files with no .cabal file
6464
, ignorePackageYaml ? false # Ignore package.yaml files even if they exist
65+
, prebuilt-depends ? []
6566
, ...
6667
}@args:
6768
let
@@ -371,6 +372,7 @@ let
371372
};
372373

373374
dummy-ghc-pkg-dump = evalPackages.runCommand "dummy-ghc-pkg-dump" {
375+
buildInputs = prebuilt-depends;
374376
nativeBuildInputs = [
375377
evalPackages.haskell-nix.nix-tools-unchecked.exes.cabal2json
376378
evalPackages.jq
@@ -535,6 +537,15 @@ let
535537
LAST_PKG="ghcjs-th"
536538
''
537539
}
540+
for l in "''${pkgsHostTarget[@]}"; do
541+
if [ -d "$l/package.conf.d" ]; then
542+
files=("$l/package.conf.d/"*.conf)
543+
for file in "''${files[@]}"; do
544+
cat "$file" >> $out
545+
echo '---' >> $out
546+
done
547+
fi
548+
done
538549
for pkg in $PKGS; do
539550
varname="$(echo $pkg | tr "-" "_")"
540551
ver="VER_$varname"

modules/cabal-project.nix

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,5 +144,10 @@ in {
144144
type = nullOr (listOf unspecified);
145145
default = [];
146146
};
147+
prebuilt-depends = mkOption {
148+
type = listOf package;
149+
default = [];
150+
description = "pre-built (perhaps proprietary) Haskell packages to make available as dependencies";
151+
};
147152
};
148153
}

modules/component-driver.nix

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ in
3737
default = [];
3838
description = "pkgs to globally provide to Setup.hs builds";
3939
};
40+
options.prebuilt-depends = lib.mkOption {
41+
type = lib.types.listOf lib.types.package;
42+
default = [];
43+
description = "pre-built (perhaps proprietary) Haskell packages to make available as dependencies";
44+
};
4045

4146
# Dependencies (with reinstallable-lib:ghc)
4247
#

overlays/haskell.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -699,6 +699,7 @@ final: prev: {
699699
in if ghc.isHaskellNixCompiler or false then ghc.override { ghcEvalPackages = evalPackages; } else ghc;
700700
compiler.nix-name = final.lib.mkForce config.compiler-nix-name;
701701
evalPackages = final.lib.mkDefault evalPackages;
702+
inherit (config) prebuilt-depends;
702703
} ];
703704
extra-hackages = config.extra-hackages or [] ++ callProjectResults.extra-hackages;
704705
};

0 commit comments

Comments
 (0)