summaryrefslogtreecommitdiffstats
path: root/pkgs/haskell/default.nix
blob: 5ab04d44089041de780e6b2a4d015f19867ddc57 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
self: super: let
  inherit (super) lib mylib;

  # Haskell projects in the development environment, i.e. directories in
  # ~/sync/src that contain <pname>.cabal.  They take precedence over
  # pkgs/haskell and nixpkgs, and can depend on each other.  On hosts without
  # ~/sync/src, there are none.
  automaticPackages =
    let
      root = /home/tv/sync/src;
    in
    lib.optionalAttrs (builtins.pathExists root)
      (lib.mapAttrs (pname: _type: root + "/${pname}")
        (lib.filterAttrs
          (pname: type: type == "directory" && builtins.pathExists (root + "/${pname}/${pname}.cabal"))
          (builtins.readDir root)));
in {
  # nixpkgs applies packageOverrides to every Haskell package set, including
  # haskellPackages.
  haskell = super.haskell // {
    packageOverrides = lib.composeExtensions super.haskell.packageOverrides
      (hself: hsuper:
        mylib.mapNixDir (path: hself.callPackage path {}) [ ./. ]
        //
        lib.mapAttrs (pname: src: hself.callCabal2nix pname (lib.cleanSource src) {}) automaticPackages);
  };
}