summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2019-11-02 14:14:26 -0700
committerBen Sima <ben@bsima.me>2019-11-02 14:14:26 -0700
commit9738540e4dbf01382b05fc16118b8269e42aef2f (patch)
treec2d8f7157c5f8e325e952f0721741286bdd2a2b7
parent468924175cfb8ca36e9dffb07cae4e645dd6e832 (diff)
provide env and app for haskell apps
-rw-r--r--com/simatime/buildHaskellApp.nix78
-rw-r--r--default.nix66
2 files changed, 70 insertions, 74 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";
+ };
}
diff --git a/default.nix b/default.nix
index ceb0d12..c5bfabd 100644
--- a/default.nix
+++ b/default.nix
@@ -74,39 +74,37 @@ in {
security.sudo.wheelNeedsPassword = true;
boot.cleanTmpDir = true;
};
- } // {
- ibb = buildHaskellApp {
- name = "Com.Influencedbybooks";
- nick = "ibb";
- apex = "Com.Influencedbybooks.Apex";
- aero = "Com.Influencedbybooks.Aero";
- deps = {
- both = [
- "clay"
- "miso"
- "protolude"
- "servant"
- "text"
- ];
- apex = [
- "MonadRandom"
- "acid-state"
- "blaze-html"
- "blaze-markup"
- "bytestring"
- "ixset"
- "random"
- "safecopy"
- "scotty"
- "servant-server"
- "text"
- ];
- aero = [
- "aeson"
- "containers"
- "ghcjs-base"
- ];
- };
+ } // (buildHaskellApp {
+ name = "Com.Influencedbybooks";
+ nick = "ibb";
+ apex = "Com.Influencedbybooks.Apex";
+ aero = "Com.Influencedbybooks.Aero";
+ deps = {
+ both = [
+ "clay"
+ "miso"
+ "protolude"
+ "servant"
+ "text"
+ ];
+ apex = [
+ "MonadRandom"
+ "acid-state"
+ "blaze-html"
+ "blaze-markup"
+ "bytestring"
+ "ixset"
+ "random"
+ "safecopy"
+ "scotty"
+ "servant-server"
+ "text"
+ ];
+ aero = [
+ "aeson"
+ "containers"
+ "ghcjs-base"
+ ];
};
- };
+ });
}