blob: 8887d3e48628f22ab38dac165f4750b03582110d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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
|
{ compiler ? "default" }: let
stockholm = import <stockholm>;
inherit (stockholm.systems.${lib.krops.getHostName}) config pkgs;
inherit (stockholm) lib;
haskellPackages =
if compiler == "default"
then pkgs.haskellPackages
else pkgs.haskell.packages.${compiler};
drv = haskellPackages.callPackage (import ./.) {};
exeName = "Reaktor";
in
lib.overrideDerivation drv.env (oldAttrs: {
shellHook = ''
pname=${lib.shell.escape (lib.baseNameOf (toString ./.))}
WORKDIR=${toString ./.}
CACHEDIR=$HOME/tmp/$pname
HISTFILE=$CACHEDIR/bash_history
mkdir -p "$CACHEDIR"
main=$CACHEDIR/main-${lib.currentSystem}
build() {(
set -efu
cd "$WORKDIR"
options=$(
${pkgs.cabal-read}/bin/ghc-options "$WORKDIR/$pname.cabal" ${exeName}
)
ghc $options \
-odir "$CACHEDIR" \
-hidir "$CACHEDIR" \
-o "$main" \
-isrc \
src/main.hs
)}
run() {(
set -efu
cd "$WORKDIR"
exec "$main" "$@"
)}
cd "$WORKDIR"
'';
})
|