diff options
author | Ben Sima <ben@bsima.me> | 2020-02-15 23:03:40 -0800 |
---|---|---|
committer | Ben Sima <ben@bsima.me> | 2020-02-16 00:37:52 -0800 |
commit | d480cce48d04d5e4353281f014f66fd61301c393 (patch) | |
tree | 395e1ed88036a9511f2197cce885c1a8a2256d64 /Com/Simatime/buildGhc.nix | |
parent | 9c01b1fc7dac01b5d2a53ffc710c24811a773904 (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/Simatime/buildGhc.nix')
-rw-r--r-- | Com/Simatime/buildGhc.nix | 54 |
1 files changed, 54 insertions, 0 deletions
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; } |