mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-10-30 14:11:21 +00:00
haskellPackages.shellFor: Add extraDependencies
An example use case is when you have Haskell scripts that use libraries that don't occur in your packages' dependencies.
This commit is contained in:
parent
99a9574518
commit
2e87d165f7
@ -384,6 +384,18 @@ in package-set { inherit pkgs lib callPackage; } self // {
|
||||
# for the "shellFor" environment (ensuring that any test/benchmark
|
||||
# dependencies for "foo" will be available within the nix-shell).
|
||||
, genericBuilderArgsModifier ? (args: args)
|
||||
|
||||
# Extra dependencies, in the form of cabal2nix build attributes.
|
||||
#
|
||||
# An example use case is when you have Haskell scripts that use
|
||||
# libraries that don't occur in your packages' dependencies.
|
||||
#
|
||||
# Example:
|
||||
#
|
||||
# extraDependencies = p: {
|
||||
# libraryHaskellDepends = [ p.releaser ];
|
||||
# };
|
||||
, extraDependencies ? p: {}
|
||||
, ...
|
||||
} @ args:
|
||||
let
|
||||
@ -474,7 +486,7 @@ in package-set { inherit pkgs lib callPackage; } self // {
|
||||
# See the Note in `zipperCombinedPkgs` for what gets filtered out from
|
||||
# each of these dependency lists.
|
||||
packageInputs =
|
||||
pkgs.lib.zipAttrsWith (_name: zipperCombinedPkgs) cabalDepsForSelected;
|
||||
pkgs.lib.zipAttrsWith (_name: zipperCombinedPkgs) (cabalDepsForSelected ++ [ (extraDependencies self) ]);
|
||||
|
||||
# A attribute set to pass to `haskellPackages.mkDerivation`.
|
||||
#
|
||||
@ -514,7 +526,7 @@ in package-set { inherit pkgs lib callPackage; } self // {
|
||||
# pkgWithCombinedDepsDevDrv :: Derivation
|
||||
pkgWithCombinedDepsDevDrv = pkgWithCombinedDeps.envFunc { inherit withHoogle; };
|
||||
|
||||
mkDerivationArgs = builtins.removeAttrs args [ "genericBuilderArgsModifier" "packages" "withHoogle" "doBenchmark" ];
|
||||
mkDerivationArgs = builtins.removeAttrs args [ "genericBuilderArgsModifier" "packages" "withHoogle" "doBenchmark" "extraDependencies" ];
|
||||
|
||||
in pkgWithCombinedDepsDevDrv.overrideAttrs (old: mkDerivationArgs // {
|
||||
nativeBuildInputs = old.nativeBuildInputs ++ mkDerivationArgs.nativeBuildInputs or [];
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
(haskellPackages.shellFor {
|
||||
packages = p: [ p.constraints p.linear ];
|
||||
extraDependencies = p: { libraryHaskellDepends = [ p.releaser ]; };
|
||||
nativeBuildInputs = [ cabal-install ];
|
||||
phases = [ "unpackPhase" "buildPhase" "installPhase" ];
|
||||
unpackPhase = ''
|
||||
@ -16,6 +17,16 @@
|
||||
export HOME=$(mktemp -d)
|
||||
mkdir -p $HOME/.cabal
|
||||
touch $HOME/.cabal/config
|
||||
|
||||
# Check extraDependencies.libraryHaskellDepends arg
|
||||
ghci <<EOF
|
||||
:m + Releaser.Primitives
|
||||
:m + System.IO
|
||||
writeFile "done" "done"
|
||||
EOF
|
||||
[[ done == $(cat done) ]]
|
||||
|
||||
# Check packages arg
|
||||
cabal v2-build --offline --verbose constraints linear --ghc-options="-O0 -j$NIX_BUILD_CORES"
|
||||
'';
|
||||
installPhase = ''
|
||||
|
Loading…
Reference in New Issue
Block a user