diff options
author | Ben Sima <ben@bsima.me> | 2019-11-02 14:14:26 -0700 |
---|---|---|
committer | Ben Sima <ben@bsima.me> | 2019-11-02 14:14:26 -0700 |
commit | 9738540e4dbf01382b05fc16118b8269e42aef2f (patch) | |
tree | c2d8f7157c5f8e325e952f0721741286bdd2a2b7 /com/simatime/buildHaskellApp.nix | |
parent | 468924175cfb8ca36e9dffb07cae4e645dd6e832 (diff) |
provide env and app for haskell apps
Diffstat (limited to 'com/simatime/buildHaskellApp.nix')
-rw-r--r-- | com/simatime/buildHaskellApp.nix | 78 |
1 files changed, 38 insertions, 40 deletions
diff --git a/com/simatime/buildHaskellApp.nix b/com/simatime/buildHaskellApp.nix index e9edb0a..ff9c741 100644 --- a/com/simatime/buildHaskellApp.nix +++ b/com/simatime/buildHaskellApp.nix @@ -1,8 +1,3 @@ -/* - -A function for building a Haskell Miso app. - -*/ nixpkgs: @@ -54,39 +49,42 @@ let ghcjs = ghcjs_.ghcWithPackages (hp: depsToPackageSet hp (deps.both ++ deps.aero)); -in stdenv.mkDerivation { - name = name; - version = "0"; - src = ../../.; # this is the git root - nativeBuildInputs = [ - ghc ghcjs guile bash - ]; - strictDeps = true; - buildPhase = '' - # capitalize paths for 'ghc --make' - source .envrc - guile -e '(com simatime caplinks)' -s ./com/simatime/caplinks.scm . - # - mkdir -p $out/{bin,static} ${basePath} - # - # compile with ghc - # - ${ghc}/bin/ghc -i. --make ${apexPath}.hs -main-is ${apex} \ - -o ${apexPath} - # - # compile with ghcjs - # - ${ghcjs}/bin/ghcjs -i. --make ${aeroPath}.hs -main-is ${aero} \ - -o ${aeroPath} - # - # optimize js output - # - ${pkgs.closurecompiler}/bin/closure-compiler \ - --compilation_level ADVANCED_OPTIMIZATIONS \ - --jscomp_off=checkVars \ - --externs=${aeroPath}.jsexe/all.js.externs \ - ${aeroPath}.jsexe/all.js > $out/static/${nick}.js - ''; - # the install process was handled above - installPhase = "exit 0"; +in { + env = ghc // ghcjs // guile; + app = stdenv.mkDerivation { + name = name; + version = "0"; + src = ../../.; # this is the git root + nativeBuildInputs = [ + ghc ghcjs guile + ]; + strictDeps = true; + buildPhase = '' + # capitalize paths for 'ghc --make' + source .envrc + guile -e '(com simatime caplinks)' -s ./com/simatime/caplinks.scm . + # + mkdir -p $out/{bin,static} ${basePath} + # + # compile with ghc + # + ${ghc}/bin/ghc -i. --make ${apexPath}.hs -main-is ${apex} \ + -o ${apexPath} + # + # compile with ghcjs + # + ${ghcjs}/bin/ghcjs -i. --make ${aeroPath}.hs -main-is ${aero} \ + -o ${aeroPath} + # + # optimize js output + # + ${pkgs.closurecompiler}/bin/closure-compiler \ + --compilation_level ADVANCED_OPTIMIZATIONS \ + --jscomp_off=checkVars \ + --externs=${aeroPath}.jsexe/all.js.externs \ + ${aeroPath}.jsexe/all.js > $out/static/${nick}.js + ''; + # the install process was handled above + installPhase = "exit 0"; + }; } |