summaryrefslogtreecommitdiff
path: root/default.nix
blob: 55f96e7a153a902e9ad561972bf6a1f0798a15df (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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
let
  nixpkgs-tar = builtins.fetchTarball (import ./nixpkgs.nix);
  nixpkgs = import "${nixpkgs-tar}" {};
  nixos = import "${nixpkgs-tar}/nixos";

  # a common build function
  #
  bild = file:
    with nixpkgs;
    let
      pack = import file;

      depsToPackageSet = packageSet: deps:
        map (s: builtins.getAttr s packageSet) deps;

      ghc844_ = pkgs.haskell.packages.ghc844.override (oldAttrs: {
        overrides = with pkgs.haskell.lib; self: super: {
          clay = dontCheck super.clay;
        };
      });

      ghc = ghc844_.ghcWithPackages (hp: depsToPackageSet hp
        # we need hinotify for chip/make
        ([ "hinotify" ] ++ pack.deps.both ++ pack.deps.apex));

      ghcjs_ = pkgs.haskell.packages.ghcjs.override (oldAttrs: {
        overrides = with pkgs.haskell.lib; self: super: {
          clay = dontCheck super.clay;
          http-types = dontCheck super.http-types;
          tasty-quickcheck = dontCheck super.tasty-quickcheck;
          scientific = dontCheck super.scientific; # takes forever
          servant = dontCheck super.servant;
          comonad = dontCheck super.comonad;
          QuickCheck = dontCheck super.QuickCheck;
        };
      });

      ghcjs = ghcjs_.ghcWithPackages (hp:
        depsToPackageSet hp (pack.deps.both ++ pack.deps.aero));

      make = ./chip/make;
    in stdenv.mkDerivation {
      name = pack.name;
      version = "0";
      src = ../.;
      nativeBuildInputs = [
        ghc ghcjs
      ];
      strictDeps = true;
      buildPhase = "${ghc}/bin/runhaskell ${make} ${pack.name}";
      installPhase = ''
        mkdir -p $out/bin
        cp bild/${pack.name} $out/bin/${pack.name}
      '';
    };
in {
  com.simatime = import ./com/simatime.nix { inherit nixos; };
  com.influencedbybooks = import ./com/influencedbybooks/default.nix {};
}