summary refs log tree commit diff
path: root/pkgs/development/haskell-modules/lib.nix
diff options
context:
space:
mode:
authorWill Fancher <elvishjerricco@gmail.com>2018-01-18 16:37:47 -0500
committerWill Fancher <elvishjerricco@gmail.com>2018-01-18 16:42:56 -0500
commit9047a7dd33030654d83f48fbb131dae984fcead3 (patch)
treeb6097aa17a3658fa3775f59b630f345fec86278e /pkgs/development/haskell-modules/lib.nix
parentc278dd0b9dd893d0a03a22286280847b38a1ee06 (diff)
downloadnixlib-9047a7dd33030654d83f48fbb131dae984fcead3.tar
nixlib-9047a7dd33030654d83f48fbb131dae984fcead3.tar.gz
nixlib-9047a7dd33030654d83f48fbb131dae984fcead3.tar.bz2
nixlib-9047a7dd33030654d83f48fbb131dae984fcead3.tar.lz
nixlib-9047a7dd33030654d83f48fbb131dae984fcead3.tar.xz
nixlib-9047a7dd33030654d83f48fbb131dae984fcead3.tar.zst
nixlib-9047a7dd33030654d83f48fbb131dae984fcead3.zip
Move packageSourceOverrides to haskellLib
Diffstat (limited to 'pkgs/development/haskell-modules/lib.nix')
-rw-r--r--pkgs/development/haskell-modules/lib.nix12
1 files changed, 12 insertions, 0 deletions
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.