Skip to content

Instantly share code, notes, and snippets.

@v0d1ch
Created August 23, 2020 21:31
Show Gist options
  • Save v0d1ch/ec9fefa3ecaef7fef90a2c5a70ea7819 to your computer and use it in GitHub Desktop.
Save v0d1ch/ec9fefa3ecaef7fef90a2c5a70ea7819 to your computer and use it in GitHub Desktop.
Nix shell with pinned unstable channel and hoogle
{ nixpkgs ? import <nixpkgs> {}, compiler ? "ghc883", withHoogle ? true }:
let
inherit (nixpkgs) pkgs;
pinnedUnstable =
pkgs.fetchFromGitHub {
owner = "NixOS";
repo = "nixpkgs-channels";
rev = "c59ea8b8a0e7f927e7291c14ea6cd1bd3a16ff38";
sha256 = "1ak7jqx94fjhc68xh1lh35kh3w3ndbadprrb762qgvcfb8351x8v";
};
unstable = import pinnedUnstable {};
finalPackage = {mkDerivation, hpack, hlint, stack, stdenv}:
mkDerivation {
pname = "banyan-backend";
version = "0.0.1";
src = ./.;
isLibrary = true;
isExecutable = true;
libraryToolDepends = [ hpack stack hlint ];
prePatch = "hpack";
license = stdenv.lib.licenses.bsd3;
shellHook = ''
export BANYAN_PASSWORD="P@ssword1";
export BANYAN_CACHE="false";
export JWT_SECRET="";
export JWT_PASSWORD="";
export JWT_KEY="";
export ICORE_BANK_LIST="test";
export BANYAN_CLIENT_URL="http://localhost:8080";
'';
};
haskellGhc =
if compiler == "default"
then pkgs.haskellGhc
else unstable.haskell.packages.${compiler};
hspkgs =
if withHoogle
then
haskellGhc.override {
overrides = (self: super: {
ghc = super.ghc // { withPackages = super.ghc.withHoogle; };
ghcWithPackages = self.ghc.withPackages;
});
}
else haskellGhc;
drv = hspkgs.callPackage finalPackage {};
in
if pkgs.lib.inNixShell then drv.env else drv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment