2022-12-08 05:08:10 +03:00
|
|
|
# define a development shell for dynamically linked applications (default)
|
2023-04-30 08:05:16 +03:00
|
|
|
{ self, pkgs, compiler, compiler-nix-name, toolsModule, withHLS ? true, withHlint ? true, withIOG ? true }:
|
2022-12-08 12:14:33 +03:00
|
|
|
let tool-version-map = import ./tool-map.nix;
|
2023-04-26 09:56:35 +03:00
|
|
|
tool = tool-name: pkgs.haskell-nix.tool compiler-nix-name tool-name [(tool-version-map compiler-nix-name tool-name) toolsModule];
|
2023-03-26 12:31:23 +03:00
|
|
|
cabal-install = tool "cabal";
|
|
|
|
# add a trace helper. This will trace a message about disabling a component despite requesting it, if it's not supported in that compiler.
|
|
|
|
compiler-not-in = compiler-list: name: (if __elem compiler-nix-name compiler-list then __trace "No ${name}. Not yet compatible with ${compiler-nix-name}" false else true);
|
2023-03-28 06:04:07 +03:00
|
|
|
|
|
|
|
# * wrapped tools:
|
2023-04-29 11:30:10 +03:00
|
|
|
# fixup-nix-deps allows us to drop dylibs from macOS executables that can be
|
|
|
|
# linked directly.
|
|
|
|
#
|
|
|
|
# FIXME: this is the same as in static.nix; and we should probably put this into
|
2023-04-30 08:05:16 +03:00
|
|
|
# a shared file. It will also not work for anything that has more than
|
2023-04-29 11:30:10 +03:00
|
|
|
# the system libs linked.
|
|
|
|
fixup-nix-deps = pkgs.writeShellApplication {
|
|
|
|
name = "fixup-nix-deps";
|
|
|
|
text = ''
|
|
|
|
for nixlib in $(otool -L "$1" |awk '/nix\/store/{ print $1 }'); do
|
|
|
|
case "$nixlib" in
|
|
|
|
*libiconv.dylib) install_name_tool -change "$nixlib" /usr/lib/libiconv.dylib "$1" ;;
|
|
|
|
*libffi.*.dylib) install_name_tool -change "$nixlib" /usr/lib/libffi.dylib "$1" ;;
|
|
|
|
*libz.dylib) install_name_tool -change "$nixlib" /usr/lib/libz.dylib "$1" ;;
|
|
|
|
*) ;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2023-03-28 06:04:07 +03:00
|
|
|
# this wrapped-cabal is for now the identity, but it's the same logic we
|
|
|
|
# have in the static configuration, and we may imagine needing to inject
|
|
|
|
# some flags into cabal (temporarily), hence we'll keep this functionality
|
|
|
|
# here.
|
|
|
|
wrapped-cabal = pkgs.writeShellApplication {
|
|
|
|
name = "cabal";
|
|
|
|
runtimeInputs = [ cabal-install ];
|
|
|
|
text = ''
|
|
|
|
case "$1" in
|
|
|
|
build) cabal "$@"
|
|
|
|
;;
|
2023-04-26 09:56:35 +03:00
|
|
|
clean|unpack) cabal "$@"
|
2023-03-28 06:04:07 +03:00
|
|
|
;;
|
|
|
|
*) cabal "$@"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
'';
|
|
|
|
};
|
2023-03-26 12:31:23 +03:00
|
|
|
in
|
2022-12-08 05:08:10 +03:00
|
|
|
pkgs.mkShell {
|
|
|
|
# The `cabal` overrride in this shell-hook doesn't do much yet. But
|
|
|
|
# we may need to massage cabal a bit, so we'll leave it in here for
|
|
|
|
# consistency with the one in static.nix.
|
|
|
|
shellHook = with pkgs; ''
|
|
|
|
export PS1="\[\033[01;33m\][\w]$\[\033[00m\] "
|
|
|
|
${figlet}/bin/figlet -f rectangles 'IOG Haskell Shell'
|
2023-04-30 08:05:16 +03:00
|
|
|
echo "Revision (input-output-hk/devx): ${if self ? rev then self.rev else "unknown/dirty checkout"}."
|
2023-04-26 09:56:35 +03:00
|
|
|
export CABAL_DIR=$HOME/.cabal
|
|
|
|
echo "CABAL_DIR set to $CABAL_DIR"
|
2023-03-26 06:36:10 +03:00
|
|
|
''
|
|
|
|
# this one is only needed on macOS right now, due to a bug in loading libcrypto.
|
2023-04-28 14:07:05 +03:00
|
|
|
# The build will error with -6 due to "loading libcrypto in an unsafe way"
|
2023-03-26 06:36:10 +03:00
|
|
|
+ lib.optionalString stdenv.hostPlatform.isMacOS
|
|
|
|
''
|
2023-04-28 14:07:05 +03:00
|
|
|
export DYLD_LIBRARY_PATH="${lib.getLib openssl}/lib"
|
2022-12-08 05:08:10 +03:00
|
|
|
'';
|
2023-03-26 06:36:10 +03:00
|
|
|
|
2022-12-08 05:08:10 +03:00
|
|
|
buildInputs = [
|
2023-03-28 06:04:07 +03:00
|
|
|
wrapped-cabal
|
2023-04-30 08:05:16 +03:00
|
|
|
fixup-nix-deps
|
2022-12-08 05:08:10 +03:00
|
|
|
compiler
|
2023-03-28 06:04:07 +03:00
|
|
|
] ++ (with pkgs; [
|
|
|
|
pkgconfig
|
2022-12-08 05:08:10 +03:00
|
|
|
# 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.
|
2023-03-28 06:04:07 +03:00
|
|
|
stdenv.cc.cc.lib
|
|
|
|
]) ++ map pkgs.lib.getDev (
|
2022-12-13 08:23:11 +03:00
|
|
|
with pkgs;
|
|
|
|
[
|
|
|
|
zlib
|
|
|
|
pcre
|
2023-03-28 06:04:07 +03:00
|
|
|
openssl
|
2022-12-13 08:23:11 +03:00
|
|
|
]
|
|
|
|
++ pkgs.lib.optional pkgs.stdenv.hostPlatform.isLinux systemd
|
|
|
|
)
|
2023-04-26 09:56:35 +03:00
|
|
|
++ pkgs.lib.optional (withHLS && (compiler-not-in (["ghc961"] ++ pkgs.lib.optional (pkgs.stdenv.hostPlatform.isDarwin && pkgs.stdenv.hostPlatform.isAarch64) "ghc902") "Haskell Language Server")) (tool "haskell-language-server")
|
|
|
|
++ pkgs.lib.optional (withHlint && (compiler-not-in (["ghc961"] ++ pkgs.lib.optional (pkgs.stdenv.hostPlatform.isDarwin && pkgs.stdenv.hostPlatform.isAarch64) "ghc902") "HLint")) (tool "hlint")
|
2023-03-26 06:36:10 +03:00
|
|
|
++ pkgs.lib.optional withIOG
|
|
|
|
(with pkgs; [ cddl cbor-diag ]
|
2023-05-05 15:31:20 +03:00
|
|
|
# R for plutus
|
|
|
|
# postgresql for db-sync
|
2023-05-18 04:21:07 +03:00
|
|
|
++ map pkgs.lib.getDev (with pkgs; [ libblst libsodium-vrf secp256k1 R_4_1_3 postgresql icu ]))
|
2022-12-08 05:08:10 +03:00
|
|
|
;
|
2023-04-28 14:07:05 +03:00
|
|
|
}
|