From e7cf3d3c66e6c72653d7548b1226d89bf8ff2a25 Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 13 Jan 2019 23:44:51 +0100 Subject: shell.nix: init --- shell.nix | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 shell.nix 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 ; + + 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" + ''; + }) -- cgit v1.2.3