summaryrefslogtreecommitdiffstats
path: root/shell.nix
blob: 4290cbb88194ef7eafef0cb95f8322affc7820b0 (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
{ nixpkgs ? import <nixpkgs> {}
, compiler ? "default"
, doBenchmark ? false
}:

let
  # cabal2nix . > regfish.nix
  packageFile = ./regfish.nix;

  inherit (nixpkgs) lib pkgs;

  haskellPackages = if compiler == "default"
                       then pkgs.haskellPackages
                       else pkgs.haskell.packages.${compiler};

  hoogle =
    haskellPackages.callPackage <nixpkgs/pkgs/development/haskell-modules/hoogle.nix> {
      packages =
        (haskellPackages.callPackage packageFile {
          mkDerivation = pkgs.lib.id;
        }).executableHaskellDepends;
    };

  variant = if doBenchmark then pkgs.haskell.lib.doBenchmark else pkgs.lib.id;

  drv = variant (haskellPackages.callPackage packageFile {
  });

in

  pkgs.lib.overrideDerivation drv.env (oldAttrs: {
    buildInputs = [
      pkgs.cabal-install
    ];
    shellHook = ''
      cd ${lib.escapeShellArg (toString ./.)}
      alias ghci='ghci -flocal-ghci-history -odir ~/tmp/regfish -hidir ~/tmp/regfish'
      export HISTFILE=.bash_history HISTSIZE=100000

      if test -e .profile; then
        . ./.profile
      fi
    '';
  })