mirror of
https://github.com/input-output-hk/devx.git
synced 2024-09-17 15:17:29 +03:00
c79eecfe19
* Fix #132: add support for GHC 9.6.4 `nix flake lock --update-input haskellNix` * Drop ghc99 * Set hlint for 9.2.8 to 3.6.1 * Bump max compiler. Maybe we want to this actually be "unreleased"? * disable hls for 9.7+ We need to find a hls (and have it in haskell.nix) that builds with 9.8 🤦 * Try to fix tools * 9.0 use lhs 2.4 * Split out IOGFull into static as well. * cleanup R * fix typo * R doesn't build for aarch64-musl * Disable R on aarch64; disable hls on -js and -windows * Disable R (libjpeg-turbo fails to build for x86_64-musl) --------- Co-authored-by: Moritz Angermann <moritz.angermann@gmail.com>
118 lines
5.2 KiB
Nix
118 lines
5.2 KiB
Nix
# define a development shell for dynamically linked applications (default)
|
|
{ self, pkgs, compiler, compiler-nix-name, toolsModule, withHLS ? true, withHlint ? true, withIOG ? true, withIOGFull ? false }:
|
|
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) toolsModule];
|
|
cabal-install = pkgs.haskell-nix.nix-tools-unchecked.exes.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);
|
|
|
|
# * wrapped tools:
|
|
# 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
|
|
# a shared file. It will also not work for anything that has more than
|
|
# 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
|
|
'';
|
|
};
|
|
|
|
# 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 pkgs.curl ];
|
|
text = ''
|
|
case "$1" in
|
|
build) cabal "$@"
|
|
;;
|
|
clean|unpack) cabal "$@"
|
|
;;
|
|
*) cabal "$@"
|
|
;;
|
|
esac
|
|
'';
|
|
};
|
|
quirks = (import ./quirks.nix { inherit pkgs; });
|
|
in
|
|
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;
|
|
let flavor = "${compiler-nix-name}"
|
|
+ lib.optionalString (!withHLS && !withHlint) "-minimal"
|
|
+ lib.optionalString withIOG "-iog"
|
|
+ lib.optionalString withIOGFull "-full"
|
|
;
|
|
in ''
|
|
export PS1="\[\033[01;33m\][\w]$\[\033[00m\] "
|
|
${figlet}/bin/figlet -f rectangles 'IOG Haskell Shell'
|
|
echo "Revision (input-output-hk/devx): ${if self ? rev then self.rev else "unknown/dirty checkout"}."
|
|
# change the CABAL_HOME so it doesn't confict with the default .cabal store outside of the shell
|
|
# which might have a different environment (and thus cflags, ldflags, ...) rendering them mutually
|
|
# incompatbile.
|
|
export CABAL_DIR=$HOME/.cabal-devx
|
|
echo "CABAL_DIR set to $CABAL_DIR"
|
|
echo ""
|
|
'' + (quirks.hint flavor)
|
|
# this one is only needed on macOS right now, due to a bug in loading libcrypto.
|
|
# The build will error with -6 due to "loading libcrypto in an unsafe way"
|
|
+ lib.optionalString stdenv.hostPlatform.isMacOS
|
|
''
|
|
export DYLD_LIBRARY_PATH="${lib.getLib openssl}/lib"
|
|
'';
|
|
|
|
buildInputs = [
|
|
wrapped-cabal
|
|
fixup-nix-deps
|
|
compiler
|
|
] ++ (with pkgs; [
|
|
(pkgs.pkg-config or pkgconfig)
|
|
# 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.
|
|
stdenv.cc.cc.lib
|
|
]) ++ map pkgs.lib.getDev (
|
|
with pkgs;
|
|
[
|
|
zlib
|
|
pcre
|
|
openssl
|
|
]
|
|
++ pkgs.lib.optional pkgs.stdenv.hostPlatform.isLinux systemd
|
|
)
|
|
++ pkgs.lib.optional (withHLS && (compiler-not-in (
|
|
pkgs.lib.optional (builtins.compareVersions compiler.version "9.7" >= 0) compiler-nix-name
|
|
++ 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 (
|
|
pkgs.lib.optional (builtins.compareVersions compiler.version "9.10" >= 0) compiler-nix-name
|
|
++ pkgs.lib.optional (pkgs.stdenv.hostPlatform.isDarwin && pkgs.stdenv.hostPlatform.isAarch64) "ghc902") "HLint")) (tool "hlint")
|
|
++ pkgs.lib.optional withIOG
|
|
(with pkgs; [
|
|
cddl
|
|
cbor-diag
|
|
gh
|
|
jq
|
|
yq-go
|
|
]
|
|
++ map pkgs.lib.getDev (with pkgs; [ libblst libsodium-vrf secp256k1 icu ]
|
|
++ pkgs.lib.optional (withIOGFull) [
|
|
(if pkgs.stdenv.hostPlatform.isAarch64 then null else R) # for plutus; R is broken on aarch64
|
|
postgresql # for db-sync
|
|
]))
|
|
;
|
|
}
|