Files
sydnix/users/crumb/programs/haskell.nix
Madeleine Sydney 3dbaa864d4 feat(emacs): Haskell
2025-03-02 21:49:06 -07:00

47 lines
1.1 KiB
Nix

{ config, lib, pkgs, ... }:
{
# Convenient shorthand for quickly opening Haskell REPLs.
programs.bash.profileExtra = ''
# Start a GHCi REPL with the given packages made available.
ghci-with-packages () {
nix-shell -p "haskellPackages.ghcWithPackages (p: with p; [ $@ ])" \
--run ghci
}
# Run GHC with the given packages made available.
ghc-with-packages () {
getopt -o "p" -- "$@"
while true; do
case "$1" in
-p)
packages="$1"
shift 2
;;
--)
shift
break
;;
esac
done
if [ $? -ne 0 ]; then
echo "Invalid options provided"
exit 1
fi
eval set -- "$options"
nix-shell -p "haskellPackages.ghcWithPackages (p: with p; [ $packages ])" \
--run "ghc $@"
}
'';
# Some global Cabal configuration.
xdg.configFile.".cabal/config".text = ''
-- Globally-enable Nix integration. See
-- https://cabal.readthedocs.io/en/3.4/nix-integration.html
nix: True
'';
}