Move packageSourceOverrides to haskellLib

This commit is contained in:
Will Fancher 2018-01-18 16:37:47 -05:00
parent c278dd0b9d
commit 9047a7dd33
2 changed files with 14 additions and 12 deletions

View File

@ -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.

View File

@ -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)