Last active
June 20, 2022 05:00
-
-
Save louispan/a0e11360e600602638c0a23c77307a33 to your computer and use it in GitHub Desktop.
Install Cabal, GHC, or GHCJS with one Nix command
This file contains 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
# install nix (5.5 mins) | |
curl https://nixos.org/nix/install | sh | |
# open a new shell to source nix | |
bash | |
# query available haskell compilers | |
nix-env -qaP -A nixpkgs.haskell.compiler [QUERY] | |
# install ghc (2.5 mins, cached binary) | |
nix-env -iA nixpkgs.haskell.compiler.ghc865 | |
# ghc is now in your PATH | |
ghc --version | |
# query cabal install version | |
nix-env -qaP -A nixpkgs.haskellPackages.cabal-install | |
# install cabal install (0.5 mins, cached binary) | |
nix-env -iA nixpkgs.haskellPackages.cabal-install | |
# cabal is now in your PATH | |
cabal --version | |
# Install ghcjs (take one sleep, build from source, with `-j1`) | |
# https://github.com/NixOS/nixpkgs/blob/67e07308236bb7a9fa11f3b599838384db650ecb/pkgs/development/compilers/ghcjs-ng/default.nix#L96 | |
# It will appear to hang at places like 'Preprocessing library for unix-2.7.2.2..' | |
# Use `ps -ef | grep nix` to check it is still doing work. | |
nix-env -iA nixpkgs.haskell.compiler.ghcjs | |
# ghcjc is now in your PATH | |
ghcjs --version | |
# cleanup disk space from unused nix stuff | |
nix-collect-garbage -d | |
# uninstall everything | |
sudo rm -rf /nix |
To build ghcjs faster, you can git clone [email protected]:NixOS/nixpkgs.git
, remove the -j1, (the -j1 flag is used to prevent an intermittent panic which might have been fixed) and then install the modified pkg
nix-env -f /path/to/cloned/nixpkgs -iA haskell.compiler.ghcjs
Thanks, I did it.😘
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
More nix commands, only if you want to use nix to install packages for reproducible releases.
Otherwise, just use cabal to build packages
query haskell packages
list pre-built packages for a specific compiler
The first segment of a package can be replaced with -f NAMESPACE