summaryrefslogtreecommitdiff
path: root/Com
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2020-02-15 23:03:40 -0800
committerBen Sima <ben@bsima.me>2020-02-16 00:37:52 -0800
commitd480cce48d04d5e4353281f014f66fd61301c393 (patch)
tree395e1ed88036a9511f2197cce885c1a8a2256d64 /Com
parent9c01b1fc7dac01b5d2a53ffc710c24811a773904 (diff)
Split buildHaskellApp into buildGhc and buildGhcjs
Two functions makes it simpler to reason about what is being built and when, even if it is a bit more explicit. I also removed the dumb Apex/Aero naming thing because Server/Client is just easier to remember.
Diffstat (limited to 'Com')
-rw-r--r--Com/InfluencedByBooks/Client.hs (renamed from Com/InfluencedByBooks/Aero.hs)2
-rw-r--r--Com/InfluencedByBooks/Server.hs (renamed from Com/InfluencedByBooks/Apex.hs)2
-rw-r--r--Com/MusicMeetsComics/Client.hs (renamed from Com/MusicMeetsComics/Aero.hs)2
-rw-r--r--Com/MusicMeetsComics/Server.hs (renamed from Com/MusicMeetsComics/Apex.hs)2
-rw-r--r--Com/Simatime/buildGhc.nix54
-rw-r--r--Com/Simatime/buildGhcjs.nix64
-rw-r--r--Com/Simatime/buildHaskellApp.nix90
7 files changed, 122 insertions, 94 deletions
diff --git a/Com/InfluencedByBooks/Aero.hs b/Com/InfluencedByBooks/Client.hs
index bd996c6..cf45511 100644
--- a/Com/InfluencedByBooks/Aero.hs
+++ b/Com/InfluencedByBooks/Client.hs
@@ -3,7 +3,7 @@
{-# LANGUAGE NoImplicitPrelude #-}
-- | Front-end
-module Com.InfluencedByBooks.Aero where
+module Com.InfluencedByBooks.Client where
import Com.InfluencedByBooks.Core (Action(..), see, init)
import Com.InfluencedByBooks.Move (move)
diff --git a/Com/InfluencedByBooks/Apex.hs b/Com/InfluencedByBooks/Server.hs
index 0328a6d..dae17ef 100644
--- a/Com/InfluencedByBooks/Apex.hs
+++ b/Com/InfluencedByBooks/Server.hs
@@ -8,7 +8,7 @@
{-# LANGUAGE TypeOperators #-}
-- | Server
-module Com.InfluencedByBooks.Apex where
+module Com.InfluencedByBooks.Server where
import qualified Clay
import Com.InfluencedByBooks.Core
diff --git a/Com/MusicMeetsComics/Aero.hs b/Com/MusicMeetsComics/Client.hs
index 26d8aaf..2dad3b7 100644
--- a/Com/MusicMeetsComics/Aero.hs
+++ b/Com/MusicMeetsComics/Client.hs
@@ -1,7 +1,7 @@
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE NoImplicitPrelude #-}
-module Com.MusicMeetsComics.Aero where
+module Com.MusicMeetsComics.Client where
import Com.MusicMeetsComics.App ( Action(..)
, Comic(..)
diff --git a/Com/MusicMeetsComics/Apex.hs b/Com/MusicMeetsComics/Server.hs
index f652f68..7bb94a2 100644
--- a/Com/MusicMeetsComics/Apex.hs
+++ b/Com/MusicMeetsComics/Server.hs
@@ -9,7 +9,7 @@
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeSynonymInstances #-}
{-# LANGUAGE NoImplicitPrelude #-}
-module Com.MusicMeetsComics.Apex where
+module Com.MusicMeetsComics.Server where
import qualified Clay
import Com.MusicMeetsComics.App
diff --git a/Com/Simatime/buildGhc.nix b/Com/Simatime/buildGhc.nix
new file mode 100644
index 0000000..489651e
--- /dev/null
+++ b/Com/Simatime/buildGhc.nix
@@ -0,0 +1,54 @@
+
+nixpkgs:
+
+{ name # the main module namespace
+, nick # a short name, for the executable
+, deps # deps get passed to ghc
+}:
+
+with nixpkgs;
+
+let
+ nsToPath = ns: builtins.toString (builtins.replaceStrings ["."] ["/"] ns);
+
+ path = nsToPath name;
+
+ depsToPackageSet = packageSet: deps:
+ map (s: builtins.getAttr s packageSet) deps;
+
+ claySrc = pkgs.fetchFromGitHub {
+ owner = "sebastiaanvisser";
+ repo = "clay";
+ rev = "cc7729b1b42a79e261091ff7835f7fc2a7ae3cee";
+ sha256 = "1vd67976lvi5l4qq18zy6j44apynkl44ps04p8vwfx4gzr895dyp";
+ };
+
+ ghc865_ = pkgs.haskell.packages.ghc865.override (oldAttrs: {
+ overrides = with pkgs.haskell.lib; self: super: {
+ clay = self.callCabal2nix "clay" claySrc {};
+ wai-middleware-metrics = dontCheck super.wai-middleware-metrics;
+ };
+ });
+
+ ghc = ghc865_.ghcWithPackages (hp: depsToPackageSet hp deps);
+
+in stdenv.mkDerivation {
+ name = name;
+ version = "0";
+ src = ../../.; # this is the git root
+ nativeBuildInputs = [ ghc ];
+ strictDeps = true;
+ buildPhase = ''
+ #
+ mkdir -p $out/{bin,static} ${path}
+ #
+ # compile with ghc
+ #
+ ${ghc}/bin/ghc -Werror -i. \
+ --make ${path}.hs \
+ -main-is ${name} \
+ -o $out/bin/${nick}
+ '';
+ # the install process was handled above
+ installPhase = "exit 0";
+} // { env = ghc; }
diff --git a/Com/Simatime/buildGhcjs.nix b/Com/Simatime/buildGhcjs.nix
new file mode 100644
index 0000000..0a88ce7
--- /dev/null
+++ b/Com/Simatime/buildGhcjs.nix
@@ -0,0 +1,64 @@
+
+nixpkgs:
+
+{ name # the main module namespace
+, nick # a short name for the output
+, deps # passed to ghcjs
+}:
+
+with nixpkgs;
+
+let
+ nsToPath = ns: builtins.toString (builtins.replaceStrings ["."] ["/"] ns);
+
+ path = nsToPath name;
+
+ depsToPackageSet = packageSet: deps:
+ map (s: builtins.getAttr s packageSet) deps;
+
+ claySrc = pkgs.fetchFromGitHub {
+ owner = "sebastiaanvisser";
+ repo = "clay";
+ rev = "cc7729b1b42a79e261091ff7835f7fc2a7ae3cee";
+ sha256 = "1vd67976lvi5l4qq18zy6j44apynkl44ps04p8vwfx4gzr895dyp";
+ };
+
+ # ghcjs-8.6.0.1
+ ghcjs_ = pkgs.haskell.packages.ghcjs.override (oldAttrs: {
+ overrides = with pkgs.haskell.lib; self: super: {
+ clay = dontCheck (self.callCabal2nix "clay" claySrc {});
+ 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);
+
+in stdenv.mkDerivation {
+ name = name;
+ version = "0";
+ src = ../../.; # the git root
+ nativeBuildInputs = [ ghcjs ];
+ strictDeps = true;
+ buildPhase = ''
+ #
+ mkdir -p $out/{bin,static} ${path}
+ #
+ # compile with ghcjs
+ #
+ ${ghcjs}/bin/ghcjs -Werror -i. \
+ --make ${path}.hs \
+ -main-is ${name} \
+ -o ${path}
+ #
+ # optimize js output
+ #
+ ${pkgs.closurecompiler}/bin/closure-compiler \
+ ${path}.jsexe/all.js > $out/static/${nick}.js
+ '';
+ installPhase = "exit 0";
+} // { env = ghcjs; }
diff --git a/Com/Simatime/buildHaskellApp.nix b/Com/Simatime/buildHaskellApp.nix
deleted file mode 100644
index c7bdd1f..0000000
--- a/Com/Simatime/buildHaskellApp.nix
+++ /dev/null
@@ -1,90 +0,0 @@
-
-nixpkgs:
-
-{ name # the namespace
-, nick # a short name, for the executable
-, deps # deps get passed to the compilers
-}:
-
-with nixpkgs;
-
-let
- nsToPath = ns: builtins.toString (builtins.replaceStrings ["."] ["/"] ns);
- pathToNs = p: builtins.replaceStrings ["/"] ["."] p;
- basePath = nsToPath name;
- apexPath = basePath + "/Apex"; # compiled with ghc
- aeroPath = basePath + "/Aero"; # compiled with ghcjs
-
- depsToPackageSet = packageSet: deps:
- map (s: builtins.getAttr s packageSet) deps;
-
- claySrc = pkgs.fetchFromGitHub {
- owner = "sebastiaanvisser";
- repo = "clay";
- rev = "cc7729b1b42a79e261091ff7835f7fc2a7ae3cee";
- sha256 = "1vd67976lvi5l4qq18zy6j44apynkl44ps04p8vwfx4gzr895dyp";
- };
-
- ghc865_ = pkgs.haskell.packages.ghc865.override (oldAttrs: {
- overrides = with pkgs.haskell.lib; self: super: {
- clay = self.callCabal2nix "clay" claySrc {};
- wai-middleware-metrics = dontCheck super.wai-middleware-metrics;
- };
- });
-
- 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 (self.callCabal2nix "clay" claySrc {});
- 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 -Werror -i. \
- --make ${apexPath}.hs \
- -main-is ${pathToNs apexPath} \
- -o $out/bin/${nick}
- #
- # compile with ghcjs
- #
- ${ghcjs}/bin/ghcjs -Werror -i. \
- --make ${aeroPath}.hs \
- -main-is ${pathToNs aeroPath} \
- -o ${aeroPath}
- #
- # optimize js output
- #
- ${pkgs.closurecompiler}/bin/closure-compiler \
- ${aeroPath}.jsexe/all.js > $out/static/${nick}.js
- '';
- # the install process was handled above
- installPhase = "exit 0";
- };
-}