Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 6 additions & 2 deletions builder/comp-builder.nix
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@
# LLVM
, useLLVM ? ghc.useLLVM or false
, smallAddressSpace ? false

, prebuilt-depends ? []
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add a comment here. As I'm a bit fuzzy on what exactly prebuilt-depends are, I'm not sure I can come up with a good comment yet.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added a new Note [prebuilt dependencies], does that help?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great! 🫰

}:
# makeOverridable is called here after all the `? DEFAULT` arguments
# will have been applied. This makes sure that `c.override (oldAttrs: {...})`
Expand Down Expand Up @@ -160,6 +162,7 @@ let self =
, enableTSanRTS
, useLLVM
, smallAddressSpace
, prebuilt-depends
}@drvArgs:

let
Expand Down Expand Up @@ -213,7 +216,7 @@ let
configFiles = makeConfigFiles {
component = componentForSetup;
inherit (package) identifier;
inherit fullName flags needsProfiling enableDWARF;
inherit fullName flags needsProfiling enableDWARF prebuilt-depends;
};

enableFeature = enable: feature:
Expand Down Expand Up @@ -852,5 +855,6 @@ in drv; in self) {
enableDWARF
enableTSanRTS
useLLVM
smallAddressSpace;
smallAddressSpace
prebuilt-depends;
}
1 change: 1 addition & 0 deletions builder/hspkg-builder.nix
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ let
inherit allComponent componentId component package name src flags setup cabalFile cabal-generator patches
shellHook
;
inherit (config) prebuilt-depends;
};

in rec {
Expand Down
27 changes: 14 additions & 13 deletions builder/make-config-files.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{ stdenv, lib, haskellLib, ghc, nonReinstallablePkgs, runCommand, writeText, writeScript }@defaults:

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

let
# Sort and remove duplicates from nonReinstallablePkgs.
Expand Down Expand Up @@ -57,7 +57,7 @@ let
((if needsProfiling then (x: map (p: p.profiled or p) x) else x: x)
(map haskellLib.dependToLib component.depends))
)
);
) ++ prebuilt-depends;
script = ''
${target-pkg} init $configFiles/${packageCfgDir}

Expand Down Expand Up @@ -149,17 +149,6 @@ let
echo "allow-older: ${identifier.name}:*" >> $configFiles/cabal.config
''}

for p in "''${pkgsHostTarget[@]}"; do
if [ -e $p/envDep ]; then
cat $p/envDep >> $configFiles/ghc-environment
fi
${ lib.optionalString component.doExactConfig ''
if [ -d $p/exactDep ]; then
cat $p/exactDep/configure-flags >> $configFiles/configure-flags
cat $p/exactDep/cabal.config >> $configFiles/cabal.config
fi
''}
done
for p in ${lib.concatStringsSep " " nonReinstallablePkgs'}; do
if [ -e $ghcDeps/envDeps/$p ]; then
cat $ghcDeps/envDeps/$p >> $configFiles/ghc-environment
Expand All @@ -172,6 +161,18 @@ let
cat $ghcDeps/exactDeps/$p/cabal.config >> $configFiles/cabal.config
fi
done
'' + ''
for p in "''${pkgsHostTarget[@]}"; do
if [ -e $p/envDep ]; then
cat $p/envDep >> $configFiles/ghc-environment
fi
${ lib.optionalString component.doExactConfig ''
if [ -d $p/exactDep ]; then
cat $p/exactDep/configure-flags >> $configFiles/configure-flags
cat $p/exactDep/cabal.config >> $configFiles/cabal.config
fi
''}
done
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did we move this down? Is this due to a quirk how we handle stuff and now with the pre-builts this would need to come later?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a comment.

''
# This code originates in the `generic-builder.nix` from nixpkgs. However GHC has been fixed
# to drop unused libraries referenced from libraries; and this patch is usually included in the
Expand Down
11 changes: 11 additions & 0 deletions lib/call-cabal-project-to-nix.nix
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
, evalPackages
, supportHpack ? false # Run hpack on package.yaml files with no .cabal file
, ignorePackageYaml ? false # Ignore package.yaml files even if they exist
, prebuilt-depends ? []
, ...
}@args:
let
Expand Down Expand Up @@ -371,6 +372,7 @@ let
};

dummy-ghc-pkg-dump = evalPackages.runCommand "dummy-ghc-pkg-dump" {
buildInputs = prebuilt-depends;
nativeBuildInputs = [
evalPackages.haskell-nix.nix-tools-unchecked.exes.cabal2json
evalPackages.jq
Expand Down Expand Up @@ -535,6 +537,15 @@ let
LAST_PKG="ghcjs-th"
''
}
for l in "''${pkgsHostTarget[@]}"; do
if [ -d "$l/package.conf.d" ]; then
files=("$l/package.conf.d/"*.conf)
for file in "''${files[@]}"; do
cat "$file" >> $out
echo '---' >> $out
done
fi
done
for pkg in $PKGS; do
varname="$(echo $pkg | tr "-" "_")"
ver="VER_$varname"
Expand Down
5 changes: 5 additions & 0 deletions modules/cabal-project.nix
Original file line number Diff line number Diff line change
Expand Up @@ -144,5 +144,10 @@ in {
type = nullOr (listOf unspecified);
default = [];
};
prebuilt-depends = mkOption {
type = listOf package;
default = [];
description = "pre-built (perhaps proprietary) Haskell packages to make available as dependencies";
};
};
}
5 changes: 5 additions & 0 deletions modules/component-driver.nix
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ in
default = [];
description = "pkgs to globally provide to Setup.hs builds";
};
options.prebuilt-depends = lib.mkOption {
type = lib.types.listOf lib.types.package;
default = [];
description = "pre-built (perhaps proprietary) Haskell packages to make available as dependencies";
};

# Dependencies (with reinstallable-lib:ghc)
#
Expand Down
1 change: 1 addition & 0 deletions overlays/haskell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,7 @@ final: prev: {
in if ghc.isHaskellNixCompiler or false then ghc.override { ghcEvalPackages = evalPackages; } else ghc;
compiler.nix-name = final.lib.mkForce config.compiler-nix-name;
evalPackages = final.lib.mkDefault evalPackages;
inherit (config) prebuilt-depends;
} ];
extra-hackages = config.extra-hackages or [] ++ callProjectResults.extra-hackages;
};
Expand Down
Loading