Newer
Older
{ haskellPackages, writeShellScriptBin, runCommand }:
let
shellrcSrcPath = ./.;
shellrcModule = "ShellRC";
shellrcSrc = shellrcSrcPath;
shellrcModulePath = builtins.replaceStrings [ "." ] [ "/" ] shellrcModule + ".hs";
ghc = haskellPackages.ghcWithPackages (p: with p; [
bytestring
containers
dhall
http-conduit
horizon-gen-nix
horizon-spec
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
lens
lens-aeson
path
procex
text
yaml
]);
args = builtins.concatStringsSep " " [
"-XDataKinds"
"-XExtendedDefaultRules"
"-XGHC2021"
"-XOverloadedStrings"
"-XOverloadedLabels"
"-Wall"
"-Wno-type-defaults"
];
shellrc = runCommand "shellrc" { } ''
cp ${shellrcSrc} --no-preserve=all -rT $out
${ghc}/bin/ghc -c -dynamic --make -i"$out" ${args} $out/${shellrcModulePath}
'';
init = runCommand "ghci-init" { } ''
cat > $out <<END
:set +m -interactive-print Text.Pretty.Simple.pPrint
:l ${shellrcModule}
import Procex.Shell.Labels
:set prompt-function promptFunction
_init
END
grep -E '^import .*$' < ${shellrcSrc}/${shellrcModulePath} >> $out
'';
in
(writeShellScriptBin "procex-shell" ''
home="$HOME/.local/share/ghci-shell"
mkdir -p "$home"
exec env GHCRTS="-c" HOME="$home" REALHOME="$HOME" ${ghc}/bin/ghci ${args} -ignore-dot-ghci -i -i${shellrc} -ghci-script ${init} "$@"
'').overrideAttrs (old: old // { passthru = { shellPath = "/bin/procex-shell"; }; })