diff --git a/pkgs/development/haskell-modules/make-package-set.nix b/pkgs/development/haskell-modules/make-package-set.nix index 86f29e731133..80dc94af4df6 100644 --- a/pkgs/development/haskell-modules/make-package-set.nix +++ b/pkgs/development/haskell-modules/make-package-set.nix @@ -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 []; diff --git a/pkgs/test/haskell/shellFor/default.nix b/pkgs/test/haskell/shellFor/default.nix index 04f5e0453619..aa06ff6e52f8 100644 --- a/pkgs/test/haskell/shellFor/default.nix +++ b/pkgs/test/haskell/shellFor/default.nix @@ -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 <