diff --git a/pkgs/development/haskell-modules/lib.nix b/pkgs/development/haskell-modules/lib.nix index bb2cf8b36f05..af1c4d5b0e88 100644 --- a/pkgs/development/haskell-modules/lib.nix +++ b/pkgs/development/haskell-modules/lib.nix @@ -40,6 +40,18 @@ rec { overrideScope = scope: overrideCabal (drv.overrideScope scope) f; }; + # : Map Name (Either Path VersionNumber) -> HaskellPackageOverrideSet + # Given a set whose values are either paths or version strings, produces + # a package override set (i.e. (self: super: { etc. })) that sets + # the packages named in the input set to the corresponding versions + packageSourceOverrides = + overrides: self: super: pkgs.lib.mapAttrs (name: src: + let isPath = x: builtins.substring 0 1 (toString x) == "/"; + generateExprs = if isPath src + then self.callCabal2nix + else self.callHackage; + in generateExprs name src {}) overrides; + /* doCoverage modifies a haskell package to enable the generation and installation of a coverage report. diff --git a/pkgs/development/haskell-modules/make-package-set.nix b/pkgs/development/haskell-modules/make-package-set.nix index b91d73c9748c..dc4d3f82bdef 100644 --- a/pkgs/development/haskell-modules/make-package-set.nix +++ b/pkgs/development/haskell-modules/make-package-set.nix @@ -139,6 +139,8 @@ in package-set { inherit pkgs stdenv callPackage; } self // { inherit mkDerivation callPackage haskellSrc2nix hackage2nix; + inherit (haskellLib) packageSourceOverrides; + callHackage = name: version: self.callPackage (self.hackage2nix name version); # Creates a Haskell package from a source package by calling cabal2nix on the source. @@ -155,18 +157,6 @@ in package-set { inherit pkgs stdenv callPackage; } self // { }; }) args) (_: { inherit src; }); - # : Map Name (Either Path VersionNumber) -> HaskellPackageOverrideSet - # Given a set whose values are either paths or version strings, produces - # a package override set (i.e. (self: super: { etc. })) that sets - # the packages named in the input set to the corresponding versions - packageSourceOverrides = - overrides: self: super: pkgs.lib.mapAttrs (name: src: - let isPath = x: builtins.substring 0 1 (toString x) == "/"; - generateExprs = if isPath src - then self.callCabal2nix - else self.callHackage; - in generateExprs name src {}) overrides; - # : { root : Path # , source-overrides : Defaulted (Either Path VersionNumber) # , overrides : Defaulted (HaskellPackageOverrideSet)