summaryrefslogtreecommitdiffstats
path: root/shell.nix
blob: 48d4bf42a921d0976c67b7090be829476117e501 (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
{ compiler ? "default"
, nixpkgs ? import <nixpkgs> {}
}: let

  inherit (nixpkgs) lib pkgs;

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

  drv = haskellPackages.callPackage (import ./package.nix) {};

in

  lib.overrideDerivation drv.env (oldAttrs: {
    buildInputs = [
      pkgs.cabal-install
    ];
    shellHook = ''
      CABAL_BUILD_DIR=$HOME/tmp/cache/${drv.pname}
      cabal() {
        command=$1; shift
        ${pkgs.cabal-install}/bin/cabal \
            "$command" \
            --builddir="$CABAL_BUILD_DIR" \
            "$@"
      }
    '';
  })