Created
February 5, 2021 19:43
-
-
Save kana-sama/0c013c7fcb90569f14fffa03737c3db6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ withHoogle ? false, forceShell ? false }: | |
# A tutorial on Nix, and how you can use 'developPackage' to override | |
# dependencies: | |
# https://www.srid.ca/1948201.html | |
let | |
pkgs = let | |
# You can get a newer ref by looking under "nixpkgs-unstable" in https://status.nixos.org/ | |
nixpkgsRev = "01ed700247e1"; | |
nixpkgsSha = "0sdcb536hrkimvnd55kzkx3ybasp3y1cbijxc2bncnkgzn2rw57k"; | |
in import (builtins.fetchTarball { | |
url = "https://github.com/nixos/nixpkgs/archive/${nixpkgsRev}.tar.gz"; | |
sha256 = nixpkgsSha; | |
}) {}; | |
# We are using the default compiler (8.8 as of this writing) in nixpkgs. | |
# To override, set it to for example: pkgs.haskell.packages.ghc865 | |
compiler = pkgs.haskellPackages; | |
gitignoreSrc = pkgs.fetchFromGitHub { | |
owner = "hercules-ci"; | |
repo = "gitignore"; | |
rev = "00b237fb1813c48e20ee2021deb6f3f03843e9e4"; | |
sha256 = "186pvp1y5fid8mm8c7ycjzwzhv7i6s3hh33rbi05ggrs7r3as3yy"; | |
}; | |
inherit (import gitignoreSrc { inherit (pkgs) ; }) gitignoreSource; | |
# happy-1.19.9 patched to work with our (older) PureScript AST, as well as | |
# GHC 8.8. | |
happy_1_19_9_patched = builtins.fetchGit { | |
url = "git+ssh://[email protected]/juspay/happy_1_19_9.git"; | |
rev = "0ff11f0622a947a7f073a765080797c59581b361"; | |
}; | |
happy9 = self: | |
pkgs.haskell.lib.dontCheck | |
(self.callCabal2nix "happy" happy_1_19_9_patched { }); | |
# purescript patched to compile with GHC 8.8 | |
purescript_patched = builtins.fetchGit { | |
url = "git+ssh://[email protected]/juspay/purescript-nau.git"; | |
rev = "cf7ce11af8ef6f88ee219bb33f836c7b36e47b96"; | |
}; | |
buildTools = with pkgs.lib.lists; [ | |
compiler.cabal-install | |
(happy9 compiler) | |
pkgs.git | |
pkgs.stack | |
]; | |
package = compiler.developPackage { | |
root = gitignoreSource ./.; | |
name = "purescript-ast-try"; | |
returnShellEnv = if forceShell then true else pkgs.lib.inNixShell; | |
source-overrides = { | |
purescript-ast = "${purescript_patched}/lib/purescript-ast"; | |
purescript-cst = "${purescript_patched}/lib/purescript-cst"; | |
}; | |
overrides = self: super: | |
with pkgs.haskell.lib; { | |
ghc = if withHoogle then | |
super.ghc // { withPackages = super.ghc.withHoogle; } | |
else | |
super.ghc; | |
ghcWithPackages = | |
if withHoogle then self.ghc.withPackages else super.ghcWithPackages; | |
happy = happy9 self; | |
purescript-ast = dontCheck super.purescript-ast; | |
purescript-cst = dontCheck super.purescript-cst; | |
# Shower's tests fail | |
shower = dontCheck super.shower; | |
}; | |
# Specify here the things you'd want available in nix-shell (and nix-build). | |
modifier = drv: | |
with pkgs.haskell.lib; | |
with pkgs.lib.trivial; | |
# The function "pipe" pipes a value through a list of functions, left to right. | |
# Type: pipe :: a -> [<functions>] -> <return type of last function> | |
pipe drv [ | |
(flip addBuildTools buildTools) | |
disableLibraryProfiling | |
dontHaddock | |
]; | |
}; | |
in package |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment