packages feed

vector-sized-1.4.2: default.nix

{ pkgs ? import <nixpkgs> {}
, compiler ? "ghc8102"
, hoogle ? true
}:

let src = pkgs.nix-gitignore.gitignoreSource [] ./.;

    # Any overrides we require to the specified haskell package set
    haskellPackages = with pkgs.haskell.lib;
      pkgs.haskell.packages.${compiler}.override {
      overrides = self: super: {
      } // pkgs.lib.optionalAttrs hoogle {
        ghc = super.ghc // { withPackages = super.ghc.withHoogle; };
        ghcWithPackages = self.ghc.withPackages;
      };
    };

    # Any packages to appear in the environment provisioned by nix-shell
    extraEnvPackages = with haskellPackages; [
    ];

    # Generate a haskell derivation using the cabal2nix tool on `package.yaml`
    drv = haskellPackages.callCabal2nix "" src {};

    # Insert the extra environment packages into the environment generated by
    # cabal2nix
    envWithExtras = pkgs.lib.overrideDerivation drv.env (attrs: {
      buildInputs = attrs.buildInputs ++ extraEnvPackages;
    } // pkgs.lib.optionalAttrs hoogle {
      shellHook   = attrs.shellHook + ''
        export HIE_HOOGLE_DATABASE="$(cat $(which hoogle) | sed -n -e 's|.*--database \(.*\.hoo\).*|\1|p')"
      '';
    });

in
  drv // { env = envWithExtras; }