Skip to content

Instantly share code, notes, and snippets.

@emmanueldenloye
Created January 2, 2019 20:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save emmanueldenloye/3f0715b633056735c71d3c81427111bd to your computer and use it in GitHub Desktop.
Save emmanueldenloye/3f0715b633056735c71d3c81427111bd to your computer and use it in GitHub Desktop.
(defun haskell-quick-nix-build ()
(interactive)
(when-let ((original-directory (file-name-directory (buffer-file-name))))
(let ((current-directory original-directory))
(while (and
(not
(or
(string= current-directory (expand-file-name "~"))
(string= current-directory (expand-file-name "/"))))
(not (directory-files current-directory nil "cabal$")))
(setq current-directory ;this is gross
(mapconcat 'identity
(reverse
(cons ""
(cdr
(cdr
(reverse
(split-string
current-directory
"/"))))))
"/")))
(unwind-protect
(not-if (directory-files current-directory nil "cabal$")
(message "Could not find a cabal file.")
(cd current-directory)
(compile "nix-shell --run \"cabal build\"" t))
(cd original-directory)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment