From 9d114cfc773171b0a95bd4d2c39f1bb0eb783c8d Mon Sep 17 00:00:00 2001
From: Ben Sima <ben@bsima.me>
Date: Sat, 2 Nov 2019 15:33:13 -0700
Subject: rename everything back to caps to appease ghc

---
 Com/Simatime/buildHaskellApp.nix | 87 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 87 insertions(+)
 create mode 100644 Com/Simatime/buildHaskellApp.nix

(limited to 'Com/Simatime/buildHaskellApp.nix')

diff --git a/Com/Simatime/buildHaskellApp.nix b/Com/Simatime/buildHaskellApp.nix
new file mode 100644
index 0000000..7f67622
--- /dev/null
+++ b/Com/Simatime/buildHaskellApp.nix
@@ -0,0 +1,87 @@
+
+nixpkgs:
+
+{
+  # the namespace. We can't figure this out with Nix code, but when we port to
+  # guix/scheme we should be able to
+  name
+, nick # a short name, for the executable
+, apex # compiled with ghc
+, aero # compiled with ghcjs
+  # deps get passed to the compilers
+, deps
+
+}:
+
+with nixpkgs;
+
+let
+  nsToPath = ns: builtins.toString (builtins.replaceStrings ["."] ["/"] ns);
+  aeroPath = nsToPath aero;
+  apexPath = nsToPath apex;
+  basePath = nsToPath name;
+
+  depsToPackageSet = packageSet: deps:
+    map (s: builtins.getAttr s packageSet) deps;
+
+  ghc865_ = pkgs.haskell.packages.ghc865.override (oldAttrs: {
+    overrides = with pkgs.haskell.lib; self: super: {
+      clay = dontCheck super.clay;
+    };
+  });
+
+  ghc = ghc865_.ghcWithPackages (hp: depsToPackageSet hp
+    (deps.both ++ deps.apex));
+
+  # ghcjs-8.6.0.1
+  ghcjs_ = pkgs.haskell.packages.ghcjs.override (oldAttrs: {
+    overrides = with pkgs.haskell.lib; self: super: {
+      clay = dontCheck super.clay;
+      http-types = dontCheck super.http-types;
+      tasty-quickcheck = dontCheck super.tasty-quickcheck;
+      scientific = dontCheck super.scientific; # takes forever
+      servant = dontCheck super.servant;
+      comonad = dontCheck super.comonad;
+      QuickCheck = dontCheck super.QuickCheck;
+    };
+  });
+
+  ghcjs = ghcjs_.ghcWithPackages (hp:
+    depsToPackageSet hp (deps.both ++ deps.aero));
+
+in {
+  inherit ghc ghcjs;
+  app = stdenv.mkDerivation {
+    name = name;
+    version = "0";
+    src = ../../.; # this is the git root
+    nativeBuildInputs = [
+      ghc ghcjs guile
+    ];
+    strictDeps = true;
+    buildPhase = ''
+      #
+      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";
+  };
+}
-- 
cgit v1.2.3