summaryrefslogtreecommitdiffstats
path: root/pkgs/haskell/default.nix
blob: 68b79b8cc031fa9a07cb095edec1756710ea8000 (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
28
29
30
31
32
33
34
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)));

  # Copies a Haskell project into the store, leaving out what the build
  # doesn't need.
  cleanHaskellSource = name: src: mylib.copyWithout {
    inherit name src;
    removeNames = [ ".git" ".graveyard" "dist-newstyle" ];
  };
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 (cleanHaskellSource pname src) {}) automaticPackages);
  };
}