aboutsummaryrefslogtreecommitdiffstats
path: root/default.nix
blob: 901ca45a60776d5576ad1cfd111ff09d10949e8d (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
{ pkgs ? import sources.nixpkgs { }
, sources ? import ./nix/sources.nix
}:
let
  haskellPackages = pkgs.haskell.packages.ghc98.override {
    overrides = self: super: {
      astore = self.callCabal2nix "astore" sources.json2sql { };
      autotypes = self.callCabal2nix "autotypes" ./autotypes { };
      backend = self.callCabal2nix "backend" ./backend { };
      common = self.callCabal2nix "common" ./common { };
      frontend = self.callCabal2nix "frontend" ./frontend { };
      websockets = pkgs.haskell.lib.doJailbreak super.websockets;
    };
  };

  jsHaskellPackages = pkgs.pkgsCross.ghcjs.haskell.packages.ghc98.override {
    overrides = self: super: {
      common = self.callCabal2nix "common" ./common { };
      frontend = self.callCabal2nix "frontend" ./frontend { };
    };
  };
in
rec {
  inherit (haskellPackages) backend;
  inherit (jsHaskellPackages) frontend;
  shell = haskellPackages.shellFor {
    packages = _: [
      haskellPackages.autotypes
      haskellPackages.backend
      haskellPackages.common
      haskellPackages.frontend
    ];
    buildInputs = [
      haskellPackages.astore
      haskellPackages.autotypes
      haskellPackages.cabal-install
      haskellPackages.ormolu
      (pkgs.writeScriptBin "reload" ''
        set -efu
        ${haskellPackages.ghcid.bin}/bin/ghcid -c \
          '${haskellPackages.cabal-install}/bin/cabal new-repl' \
          -T ':run Main.main'
      '')
    ];
    withHoogle = true;
    withHaddock = true;
  };
}