Skip to content

Commit

Permalink
Fix issue #26: [macOS] DYLD_LIBRARY_PATH env var needed for dev shell
Browse files Browse the repository at this point in the history
  • Loading branch information
yvan-sraka committed Mar 13, 2023
1 parent 7420ccb commit 46f543c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
9 changes: 6 additions & 3 deletions dynamic.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ pkgs.mkShell {
${figlet}/bin/figlet -f rectangles 'IOG Haskell Shell'
function cabal() {
case "$1" in
build)
case "$1" in
build)
${cabal-install}/bin/cabal "$@"
;;
clean)
Expand All @@ -24,7 +24,10 @@ pkgs.mkShell {
;;
esac
}
'';
'' ++ (if systems == "darwin-aarch64" || systems == "darwin-x86_64" then ''
# this one is only needed on macOS right now, due to a bug in loading libcrypto.
export DYLD_LIBRARY_PATH=$(pkg-config --libs-only-L libcrypto|cut -c 3-)
'' else "");
buildInputs = [
compiler
cabal-install
Expand Down
18 changes: 11 additions & 7 deletions static.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
let tool-version-map = import ./tool-map.nix;
tool = tool-name: pkgs.haskell-nix.tool compiler-nix-name tool-name (tool-version-map compiler-nix-name tool-name);
cabal-install = tool "cabal"; in
pkgs.mkShell (rec {
pkgs.mkShell ({
# Note [cabal override]:
#
# We need to override the `cabal` command and pass --ghc-options for the
Expand Down Expand Up @@ -34,7 +34,7 @@ pkgs.mkShell (rec {
'';

shellHook = with pkgs; ''
export PS1="\[\033[01;33m\][\w]$\[\033[00m\] "
export PS1="\[\033[01;33m\][\w]$\[\033[00m\] "
${figlet}/bin/figlet -f rectangles 'IOG Haskell Shell'
${figlet}/bin/figlet -f small "*= static edition =*"
echo "NOTE (macos): you can use fixup-nix-deps FILE, to fix iconv, ffi, and zlib dependencies that point to the /nix/store"
Expand All @@ -44,8 +44,8 @@ pkgs.mkShell (rec {
echo -e "\tif you have the zlib, HsOpenSSL, or digest package in your dependency tree, please make sure to"
echo -e "\techo \"\$CABAL_PROJECT_LOCAL_TEMPLATE\" > cabal.project.local"
function cabal() {
case "$1" in
build)
case "$1" in
build)
${cabal-install}/bin/cabal \
"$@" \
$NIX_CABAL_FLAGS \
Expand Down Expand Up @@ -74,7 +74,11 @@ pkgs.mkShell (rec {
esac
done
}
'';
'' ++ (if systems == "darwin-aarch64" || systems == "darwin-x86_64" then ''
# this one is only needed on macOS right now, due to a bug in loading libcrypto.
export DYLD_LIBRARY_PATH=$(pkg-config --libs-only-L libcrypto|cut -c 3-)
'' else "");
buildInputs = (with pkgs; [
# for libstdc++; ghc not being able to find this properly is bad,
# it _should_ probably call out to a g++ or clang++ but doesn't.
Expand All @@ -95,5 +99,5 @@ pkgs.mkShell (rec {
])
++ pkgs.lib.optional withHLS (tool "haskell-language-server")
++ pkgs.lib.optional withHlint (tool "hlint")
;
})
;
})

0 comments on commit 46f543c

Please sign in to comment.