knupfer / haskell-emacs

Write Emacs extensions in Haskell
375 stars 22 forks source link

Building through Cabal and Nix #73

Open walseb opened 7 months ago

walseb commented 7 months ago

Hello!

Is anyone able to build this package through Cabal or Nix?

For me, Nix tells me atto-lisp is marked as broken and won't build.

Cabal can't build atto-lisp either, due to a too old base being set.

I tried cloning atto-lisp and removing that limitation, but now it seems like Happy won't build:

Failed to build haskell-src-exts-1.23.1. The failure occurred during the
configure step.
Build log (
/home/admin/.cabal/logs/ghc-9.4.8/haskell-src-exts-1.23.1-82eadf38c5bdf000e30b879f83308c1693e4ed1205ee33cd26bd817cae88a0e5.log
):
Configuring library for haskell-src-exts-1.23.1..
Error: .cabal-wrapped: The program 'happy' version >=1.19 is required but the
version of /home/admin/.cabal/bin/happy could not be determined.

Error: cabal: Failed to build haskell-src-exts-1.23.1 (which is required by
exe:HaskellEmacs from HaskellEmacs-0.0.0). See the build log above for
details.

Thoughts?

walseb commented 6 months ago

For those wanting to build this on Cabal, you need to clone this: https://github.com/francesquini/atto-lisp Create a cabal.project pointing to it (simply insert something like packages: ./ ./deps/atto-lisp), and then do a bunch of overrides as this was written prior to cabal v2:

(with-eval-after-load 'haskell-emacs
  (defun haskell-emacs--compile-command (heB)
    "Compile haskell-emacs with buffer HEB."
    (if (eql 1 ;; If this doesn't work for you, I would remove this check. I don't know why my cabal outputs 1.
             (progn (message "Compiling ...")
                    (setq test (+ (call-process "cabal" nil heB nil "init")
                                  ;; (call-process "cabal" nil heB nil "install" "happy" "--overwrite-policy=always") -- just install as a system dependency instead of having cabal install it
                                  (call-process "cabal" nil heB nil "install" "--overwrite-policy=always")))))
        (progn
          (message "Haskell compilation success!")
          (kill-buffer heB))
      (let ((bug (with-current-buffer heB (buffer-string))))
        (kill-buffer heB)
        (error bug))))

  (defun haskell-emacs--set-bin ()
    "Set the path of the executable."
    (setq haskell-emacs--bin "~/.local/bin/HaskellEmacs")))

Also remember to enable cabal

(setq haskell-emacs-build-tool 'cabal)

I think the package needs a bit of a rewrite which I might get to some day.

Brilliant package nonetheless!