diff options
author | tv <tv@krebsco.de> | 2019-01-13 23:44:51 +0100 |
---|---|---|
committer | tv <tv@krebsco.de> | 2019-01-21 00:19:34 +0100 |
commit | e7cf3d3c66e6c72653d7548b1226d89bf8ff2a25 (patch) | |
tree | 43e58445d86aeded76c07b925bf01f02c4de965b | |
parent | 5371e75c194770b1bca60d3ff6bca109b3eb0033 (diff) |
shell.nix: init
-rw-r--r-- | shell.nix | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..8887d3e --- /dev/null +++ b/shell.nix @@ -0,0 +1,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" + ''; + }) |