Skip to content

Instantly share code, notes, and snippets.

@gilligan
Last active June 29, 2018 09:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save gilligan/f1a94da585191fe7184c to your computer and use it in GitHub Desktop.
Save gilligan/f1a94da585191fe7184c to your computer and use it in GitHub Desktop.
Getting started with nix and haskell
{ pkgs }:
{
allowBroken = true;
allowUnfree = true;
haskellPackageOverrides = self : super : (let inherit (pkgs.haskell-ng) lib; in {
ghc-mod = lib.overrideCabal super.ghc-mod (oldAttrs: {
src = pkgs.fetchgit {
url = https://github.com/kazu-yamamoto/ghc-mod;
rev = "247e4e0e7616fe1fecc68fdcf80d6249ac4cee4f";
sha256 = "2a23271d0e6907351a246f095040ba18c3ab6bf1cba08a14338d701defa55474";
};
buildDepends = oldAttrs.buildDepends ++ [ self.cabal-helper self.cereal ];
patchPhase = "${pkgs.gnused}/bin/sed -i 's/Version:\ *0/Version:5.0.1.1/' ghc-mod.cabal";
});
cabal-helper = lib.overrideCabal super.cabal-helper (oldAttrs: {
version = "0.3.2.0";
sha256 = "06igjmr0n8418wid1pr74cgvlsmwni7ar72g9bddivlbxax1pfli";
});
halive = self.callPackage ./haskell/halive {};
});
packageOverrides = pkgs : rec {
devTools = with pkgs; buildEnv {
name = "devTools";
paths = [
neovim
zeal
];
};
ghcEnv = pkgs.haskellngPackages.ghcWithPackages (p : with p; [
alex
cabal2nix
cabal-install
codex
ghc
ghcid
ghc-mod
halive
hasktags
hdevtools
hlint
happy
hoogle
hspec
purescript
]);
nodeEnv = with pkgs; buildEnv {
name = "node";
paths = [
nodejs
] ++ (with nodePackages; [
npm2nix
]);
};
};
}
nix-search(){ nix-env -qa \* -P | grep -i "$1"; }
nsh() { nix-shell -E 'with (import <nixpkgs> {}).pkgs; (haskellngPackages.callPackage ./default.nix {}).env' "$@" }
@gilligan
Copy link
Author

gilligan commented Jun 1, 2015

getting started with nixos

install nix

Get it from nixos.org/nix - After installation you should have nix-env and various others nix commands in your path.

Get nixpkgs master

clone nixpkgs : https://github.com/NixOS/nixpkgs - This is the bleeding edge. I did my setup with nixpkgs but it should work the same way if you stick to the 14.12 channel. You decide. If you want to use master then the nix-channel command is basically meaningless to you. You update your packages (nix expressions) by pulling the nixpkgs repo. Otherwise you use nix-channel --update to update. In order to tell nix to use binary caches (to prevent compiling everything) save the nix.conf file at /etc/nix/nix.conf.

If you want to use 14.12 do a nix-channel --update right now and skip the next paragraph.

Remove the link in the $(HOME)/.nix-defexpr directory and create a link to your nixpkgs clone: ln -s /path/to/nixpkgs nixpkgs

Install Tools

Now its time to install ghc and whatever else you want to use for your haskell hacking. First copy the config.nix file to $(HOME)/.nixpkgs. Then use ghc-env -i ghcEnv to install everything listed in the ghcEnv environment. Of course you should first remove anything you are not interested in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment