Skip to content

Instantly share code, notes, and snippets.

@DeCentN2Madness
Forked from oneingan/init-haskell.sh
Created September 12, 2022 02:12
Show Gist options
  • Save DeCentN2Madness/20cc9a74af8abcc93112c2bcae9a2031 to your computer and use it in GitHub Desktop.
Save DeCentN2Madness/20cc9a74af8abcc93112c2bcae9a2031 to your computer and use it in GitHub Desktop.
Basic nix haskell setup
#!/usr/bin/env bash
set -Eeuxo pipefail
# Set up niv
niv init
niv update nixpkgs -b nixos-unstable
niv add Infinisil/all-hies
# Create cabal project
export currentdir=${PWD##*/}
cabal init -n -m --is-libandexe --source-dir src --main-is Main.hs -p $currentdir
# Add default.nix
cat << 'EOF' > ./default.nix
let
compilerVersion = "ghc865";
sources = import ./nix/sources.nix;
pkgs = import sources.nixpkgs {};
hie = (import sources.all-hies {}).versions."${compilerVersion}";
in
with pkgs;
let
hpkgs = haskell.packages."${compilerVersion}";
btools = [
hpkgs.cabal-install
hpkgs.ghcid
hpkgs.hoogle
hpkgs.stylish-cabal
hie
];
modifier = drv: haskell.lib.addBuildTools drv btools;
in
hpkgs.developPackage { root = ./.; inherit modifier; }
EOF
# Create direnv file
cat << 'EOF' > .envrc
use nix
EOF
direnv allow
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment