From b01be33386707d6b0cdceb5b43b4c68abc52d887 Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Tue, 5 Jun 2018 21:29:37 -0700 Subject: [PATCH] [Emacs] Only enable lsp-haskell when hie binary exists --- dotfiles/config/xmonad/build | 31 +++++++++++++++++++++++++++++-- dotfiles/config/xmonad/stack.yaml | 9 +++++++++ dotfiles/emacs.d/README.org | 3 ++- dotfiles/lib/bin/xmonad | 10 ---------- 4 files changed, 40 insertions(+), 13 deletions(-) delete mode 100755 dotfiles/lib/bin/xmonad diff --git a/dotfiles/config/xmonad/build b/dotfiles/config/xmonad/build index a1ecc97b..5b93498c 100755 --- a/dotfiles/config/xmonad/build +++ b/dotfiles/config/xmonad/build @@ -1,9 +1,36 @@ #!/usr/bin/env bash +function min { + [ $1 -le $2 ] && echo "$1" || echo "$2" +} + +function get_exe_dir { + # XXX: This exists because calling in to stack is kind of slow with nix + # integration enabled, even when just using it to get a path. + if [ -e ./.cached-stack-install-path ]; then + cat .cached-stack-install-path + else + stack path --local-install-root + fi +} + +function do_rebuild { + +} + SRC_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" EXE_NAME=imalison-xmonad +EXE_LOCATION=$(get_exe_dir)/bin/$EXE_NAME output_file=$1; shift -stack install -cp -uf $(stack path --local-install-root)/bin/$EXE_NAME $output_file +if [ -e ./.cached-stack-install-path ]; then + last_built=$(stat -c '%Y' $EXE_LOCATION) + xmonad_modified=$(stat -c '%Y' ./xmonad.hs) + + [ $last_built -lt $xmonad_modified ] && stack install +else + stack install +fi + +cp -uf $EXE_LOCATION $output_file diff --git a/dotfiles/config/xmonad/stack.yaml b/dotfiles/config/xmonad/stack.yaml index 045170ce..8e09048c 100644 --- a/dotfiles/config/xmonad/stack.yaml +++ b/dotfiles/config/xmonad/stack.yaml @@ -9,3 +9,12 @@ packages: extra-deps: - X11-xft-0.3.1 resolver: lts-11.7 +nix: + packages: + - pkgconfig + - x11 + - xorg.libX11 + - xorg.libXext + - xorg.libXinerama + - xorg.libXrandr + - xorg.libXrender diff --git a/dotfiles/emacs.d/README.org b/dotfiles/emacs.d/README.org index 191bf95b..23a2a700 100644 --- a/dotfiles/emacs.d/README.org +++ b/dotfiles/emacs.d/README.org @@ -2774,7 +2774,8 @@ The following is taken from [[https://github.com/syl20bnr/spacemacs/blob/a650877 #+BEGIN_SRC emacs-lisp (use-package lsp-haskell :config - (add-hook 'haskell-mode-hook 'lsp-haskell-enable)) + (when (executable-find "hie") + (add-hook 'haskell-mode-hook 'lsp-haskell-enable))) #+END_SRC **** intero Intero seems to be causing hangs, so it has been disabled diff --git a/dotfiles/lib/bin/xmonad b/dotfiles/lib/bin/xmonad deleted file mode 100755 index 47e6a2c5..00000000 --- a/dotfiles/lib/bin/xmonad +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env zsh -# -*- mode:sh - -if command_exists "imalison-taffybar"; then - imalison-xmonad "$@" -else - # Move .lib/bin to the end of PATH so that this script is not called again - add_to_path "$HOME/.lib/bin" --after - xmonad "$@" -fi