 
 (defhydra hydra-haskell (:hint nil)
   "
-^Imports^     ^GHCi^        ^Insert^            ^Run
+^Imports^     ^GHCi^        ^Insert/Edit^       ^Run
 ^^^^^^^^^----------------------------------------------------
 _i_: jump     _g_: ghci     _S_: cost center    _c_: compile
-_I_: return   _r_: reload   ^ ^                 _R_: run
-_s_: sort     _t_: type     ^ ^
+_I_: return   _r_: reload   _m_: new module     _R_: run
+_s_: sort     _t_: type     _M_: kill module
+^ ^           ^ ^           _e_: edit cabal
 "
-  ("i" haskell-navigate-imports)
   ("I" haskell-navigate-imports-return :color blue)
-  ("s" haskell-sort-imports)
-  ("g" haskell-interactive-switch :color blue)
-  ("r" haskell-process-reload)
-  ("t" haskell-process-do-type :color blue)
+  ("M" pjones:haskell-module-name-to-kill-ring :color blue)
+  ("R" projectile-run-project :color blue)
   ("S" haskell-mode-toggle-scc-at-point :color blue)
   ("c" pjones:haskell-compile :color blue)
-  ("R" projectile-run-project :color blue))
+  ("e" pjones:haskell-edit-cabal-file :color blue)
+  ("g" haskell-interactive-switch :color blue)
+  ("i" haskell-navigate-imports)
+  ("m" pjones:haskell-new-module :color blue)
+  ("r" haskell-process-reload)
+  ("s" haskell-sort-imports)
+  ("t" haskell-process-do-type :color blue))
 
 (define-skeleton pjones:haskell-insert-pragma
   "Add the pragma comment syntax." nil "{-# " _ " #-}")
+
+(defun pjones:haskell-nixpkgs-wrapper-function (argv)
+  "Function that can be used with the
+`haskell-process-wrapper-function' variable to force building
+with my custom nix-hs-shell script."
+  (append (list "nix-hs-shell" "--run")
+          (list (mapconcat 'identity argv " "))))
 
 (defun pjones:haskell-mode-hook ()
   "Hook run on new Haskell buffers."

  "Save the module name of the current buffer to the kill ring."
  (interactive)
  (kill-new (pjones:haskell-module-name)))

(defun pjones:haskell-lint-all ()
  "Run hlint from a directory containing a .cabal file."
  (interactive)
  (let* ((dir (pjones:haskell-find-cabal-file))
         (files (cl-remove-if
                 (lambda (f)
                   (or (string-match "^\\." (file-name-base f))
                       (string= "dist"      (file-name-base f))
                       (string= "cabal-dev" (file-name-base f))
                       (and (not (file-directory-p f))
                            (not (string= "hs" (file-name-extension f))))))
                 (directory-files dir t))))
    (haskell-check (concat "hlint " (mapconcat 'identity files " ")))))

(defun pjones:haskell-smart-newline ()
  "Insert a new line below point that looks like the current

  (require 'haskell-indentation)
  (require 'haskell-mode))

;; Settings for haskell-mode and friends:
(custom-set-variables
  '(haskell-stylish-on-save nil)
  '(haskell-completing-read-function 'ivy-completing-read)
  '(haskell-indentation-layout-offset 0)
  '(haskell-indentation-starter-offset 2)
  '(haskell-indentation-left-offset 2)
  '(haskell-indentation-ifte-offset 2)
  '(haskell-indentation-where-pre-offset 2)
  '(haskell-indentation-where-post-offset 2)
  '(haskell-compile-cabal-build-command "make")
  '(haskell-process-type 'stack-ghci)
  '(haskell-process-suggest-language-pragmas t)
  '(haskell-process-suggest-remove-import-lines t)
  '(haskell-interactive-popup-errors nil)
  '(haskell-process-wrapper-function 'identity))

(defun pjones:haskell-find-cabal-file ()
  "Return the full path to the *.cabal file for the current project."
  (let* ((dir default-directory)
