From 5dea32c8b804c24ee0bc8c75b14f93b43772b47f Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Sat, 23 Feb 2019 21:46:13 -0800 Subject: Get rid of cabal Using just nix and ghc, ah it's so nice. --- .gitignore | 2 +- README.md | 11 ++-- apex/Ibb.hs | 117 +++++++++++++++++++++++++++++++++++++ apex/Main.hs | 117 ------------------------------------- bild/.keep | 0 depo/nutin-madaj/configuration.nix | 2 +- pack/default.nix | 7 ++- pack/ibb.nix | 51 +++++++++------- pack/overlay.nix | 3 + 9 files changed, 161 insertions(+), 149 deletions(-) create mode 100644 apex/Ibb.hs delete mode 100644 apex/Main.hs create mode 100644 bild/.keep create mode 100644 pack/overlay.nix diff --git a/.gitignore b/.gitignore index d15abda..332bc9e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ *.o *.exe *.hi -result +result* dist dist-newstyle diff --git a/README.md b/README.md index 7ad271d..c113a4d 100644 --- a/README.md +++ b/README.md @@ -4,11 +4,12 @@ aero browser apps, compiled with ghcjs apex server-side api stuff + bild temporary storage for build artifacts chip executable scripts in python, bash depo for deployment, machine-specific nix code, like networking.nix lore shared code, libraries, general code mode nixos modules; services and modular config - pack nix packages, like ibb/default.nix, & external packages that we import + pack nix packages & external packages that we import soar s3/spaces assets, like images, via git-annex Makefile instructions for building the artifacts default.nix contains all the build stuff, combines everything, builds the entire system @@ -19,13 +20,13 @@ This isn't totally in place yet, but it's something to work toward. To get a development shell, for example to work on ibb, you can do: - $ nix-shell pack/ibb.nix + $ nix-shell pack --attr ibb $ ghci - GHCi, version 8.4.3: http://www.haskell.org/ghc/ :? for help + GHCi, version 8.4.4: http://www.haskell.org/ghc/ :? for help Loaded GHCi configuration from /home/ben/src/biz/.ghci - λ :load apex/Main.hs + λ :load apex/Ibb.hs [1 of 2] Compiling Influencers ( apex/Influencers.hs, interpreted ) - [2 of 2] Compiling Main ( apex/Main.hs, interpreted ) + [2 of 2] Compiling Ibb ( apex/Ibb.hs, interpreted ) Ok, two modules loaded. # Deployment diff --git a/apex/Ibb.hs b/apex/Ibb.hs new file mode 100644 index 0000000..1472811 --- /dev/null +++ b/apex/Ibb.hs @@ -0,0 +1,117 @@ +{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE QuasiQuotes #-} + +module Ibb where + +import Control.Monad.IO.Class (liftIO) +import Data.ByteString.Lazy (ByteString) +import Data.Maybe (fromMaybe) +import Data.Text.Lazy (Text) +import Data.Text.Lazy.Encoding (encodeUtf8) +import Influencers (Person(..), Book(..), allPeople) +import System.Environment (lookupEnv) +import System.Random (newStdGen) +import System.Random.Shuffle (shuffle') +import Text.Blaze (Markup) +import Text.Blaze.Html (Html) +import Text.Blaze.Html.Renderer.Text (renderHtml) +import Text.Hamlet (shamlet) +import Text.Lucius (lucius, renderCss) +import Web.Scotty (ActionM, ScottyM, scotty, get, html, raw, setHeader) + +render :: Html -> ActionM () +render = html . renderHtml + +css :: ByteString -> ActionM () +css src = setHeader "content-type" "text/css" >> raw src + +main :: IO () +main = do + port <- read <$> fromMaybe "3000" <$> lookupEnv "PORT" :: IO Int + scotty port routes + +routes :: ScottyM () +routes = do + get "/" $ do + r <- liftIO newStdGen + let peopleList = shuffle' allPeople (length allPeople) r + render (homepage peopleList) + get "/custom.css" $ css stylesheet + +displayPerson :: Person -> Markup +displayPerson person = [shamlet| +
+ +
+

+ #{_name person} +

+ + +

+