summaryrefslogtreecommitdiff
path: root/com/simatime/buildHaskellApp.nix
diff options
context:
space:
mode:
Diffstat (limited to 'com/simatime/buildHaskellApp.nix')
-rw-r--r--com/simatime/buildHaskellApp.nix79
1 files changed, 79 insertions, 0 deletions
diff --git a/com/simatime/buildHaskellApp.nix b/com/simatime/buildHaskellApp.nix
new file mode 100644
index 0000000..d9cb211
--- /dev/null
+++ b/com/simatime/buildHaskellApp.nix
@@ -0,0 +1,79 @@
+/*
+
+A function for building a Haskell Miso app.
+
+*/
+
+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
+, apex # compiled with ghc
+, aero # compiled with ghcjs
+ # deps get passed to GHC
+, deps
+
+}:
+
+with nixpkgs;
+
+let
+ nsToPath = ns:
+ builtins.toString (builtins.replaceStrings ["."] ["/"] ns);
+
+ depsToPackageSet = packageSet: deps:
+ map (s: builtins.getAttr s packageSet) deps;
+
+ ghc844_ = pkgs.haskell.packages.ghc844.override (oldAttrs: {
+ overrides = with pkgs.haskell.lib; self: super: {
+ clay = dontCheck super.clay;
+ };
+ });
+
+ ghc = ghc844_.ghcWithPackages (hp: depsToPackageSet hp
+ (deps.both ++ deps.apex));
+
+ 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 stdenv.mkDerivation {
+ name = name;
+ version = "0";
+ src = ../../.; # this is the git root
+ nativeBuildInputs = [
+ ghc ghcjs guile bash
+ ];
+ strictDeps = true;
+ buildPhase = ''
+ echo ":: build"
+ . .envrc
+ guile -e '(com simatime caplinks)' -s ./com/simatime/caplinks.scm .
+ mkdir -p _bild/${nsToPath apex}
+ mkdir -p _bild/${nsToPath aero}
+ ${ghc}/bin/ghc -i. --make ${nsToPath apex}.hs -main-is ${apex} \
+ -o _bild/${nsToPath apex}
+ ${ghcjs}/bin/ghcjs -i. --make ${nsToPath aero}.hs -main-is ${aero} \
+ -o _bild/${nsToPath aero}
+ '';
+ installPhase = ''
+ echo ":: install"
+ mkdir -p $out
+ pwd && ls -al .
+ cp -r ./${nsToPath apex}* $out/${apex}
+ cp -r ./${nsToPath aero}* $out/${aero}
+ '';
+}