From f75eaf7fff963b88e412d315d0fdef8151943c20 Mon Sep 17 00:00:00 2001 From: Ben Sima <ben@bsima.me> Date: Sat, 23 Feb 2019 19:46:09 -0800 Subject: Reorganize directory --- .ghci | 3 + LICENSE | 1 + Makefile | 2 +- README.md | 28 ++ apex/Influencers.hs | 393 ++++++++++++++++++++++++++++ apex/Main.hs | 117 +++++++++ biz.cabal | 30 +++ configuration.nix | 103 -------- depo/nutin-madaj/configuration.nix | 103 ++++++++ depo/nutin-madaj/default.nix | 25 ++ depo/nutin-madaj/hardware-configuration.nix | 6 + depo/nutin-madaj/networking.nix | 30 +++ hardware-configuration.nix | 6 - ibb/Influencers.hs | 393 ---------------------------- ibb/LICENSE | 1 - ibb/Main.hs | 117 --------- ibb/default.nix | 23 -- ibb/ibb.cabal | 30 --- mode/fathom.nix | 93 +++++++ mode/ibb.nix | 42 +++ modules/fathom.nix | 93 ------- modules/ibb.nix | 42 --- networking.nix | 30 --- nixos.nix | 27 -- pack/default.nix | 2 +- pack/ibb.nix | 23 ++ 26 files changed, 896 insertions(+), 867 deletions(-) create mode 100644 .ghci create mode 100644 LICENSE create mode 100644 apex/Influencers.hs create mode 100644 apex/Main.hs create mode 100644 biz.cabal delete mode 100644 configuration.nix create mode 100644 depo/nutin-madaj/configuration.nix create mode 100644 depo/nutin-madaj/default.nix create mode 100644 depo/nutin-madaj/hardware-configuration.nix create mode 100644 depo/nutin-madaj/networking.nix delete mode 100644 hardware-configuration.nix delete mode 100644 ibb/Influencers.hs delete mode 100644 ibb/LICENSE delete mode 100644 ibb/Main.hs delete mode 100644 ibb/default.nix delete mode 100644 ibb/ibb.cabal create mode 100644 mode/fathom.nix create mode 100644 mode/ibb.nix delete mode 100644 modules/fathom.nix delete mode 100644 modules/ibb.nix delete mode 100644 networking.nix delete mode 100644 nixos.nix create mode 100644 pack/ibb.nix diff --git a/.ghci b/.ghci new file mode 100644 index 0000000..49e87da --- /dev/null +++ b/.ghci @@ -0,0 +1,3 @@ +:set -iapex +:set prompt "λ " +:set prompt-cont "| " diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..1d1026a --- /dev/null +++ b/LICENSE @@ -0,0 +1 @@ +All rights reserved. \ No newline at end of file diff --git a/Makefile b/Makefile index ab22c0b..8ddaa9b 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ USER = root OUT = $(shell readlink -n ./result) result: - nix-build --attr system ./nixos.nix + nix-build --attr system ./depo/nutin-madaj copy: result nix copy --to "ssh://$(USER)@$(HOST)" ./result diff --git a/README.md b/README.md index 57ba3f4..7ad271d 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,33 @@ [](https://builds.sr.ht/~ben/biz?) +# Source layout + + aero browser apps, compiled with ghcjs + apex server-side api stuff + 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 + 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 + +This isn't totally in place yet, but it's something to work toward. + +# Development + +To get a development shell, for example to work on ibb, you can do: + + $ nix-shell pack/ibb.nix + $ ghci + GHCi, version 8.4.3: http://www.haskell.org/ghc/ :? for help + Loaded GHCi configuration from /home/ben/src/biz/.ghci + λ :load apex/Main.hs + [1 of 2] Compiling Influencers ( apex/Influencers.hs, interpreted ) + [2 of 2] Compiling Main ( apex/Main.hs, interpreted ) + Ok, two modules loaded. + # Deployment To build the production server config locally: diff --git a/apex/Influencers.hs b/apex/Influencers.hs new file mode 100644 index 0000000..7a7031f --- /dev/null +++ b/apex/Influencers.hs @@ -0,0 +1,393 @@ +{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE QuasiQuotes #-} + +module Influencers where + +import Data.Text.Lazy (Text) + +data Person = Person + { _name :: Text + , _pic :: Text + , _twitter :: Text + , _website :: Text + , _books :: [Book] + } + +data Book = Book + { _title :: Text + , _author :: Text + , _amznref :: Text + } + +allPeople :: [Person] +allPeople = + [ Person { _name = "Joe Rogan" + , _pic = "https://pbs.twimg.com/profile_images/552307347851210752/vrXDcTFC_400x400.jpeg" + , _twitter = "joerogan" + , _website = "http://joerogan.com" + , _books = [ Book {_title = "Food of the Gods" + , _author = "Terence McKenna" + , _amznref = "0553371304" + } + , Book { _title = "The War of Art" + , _author ="Steven Pressfield" + , _amznref ="B007A4SDCG" + } + ] + } + , Person { _name = "Beyoncé" + , _pic = "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTxT84sF19lxdnSiblIXAp-Y4wAigpQn8sZ2GtAerIR_ApiiEJfFQ" + , _twitter = "Beyonce" + , _website = "http://beyonce.com" + , _books = [ Book { _title = "What Will It Take To Make A Woman President?" + , _author = "Marianne Schnall" + , _amznref = "B00E257Y7G"} + ] + } + , Person { _name = "Barrack Obama" + , _pic = "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQeLzftR36p0hYI-EKNa5fm7CYDuN-vyz23_R48ocqa8X1nPr6C" + , _twitter = "BarackObama" + , _website = "http://barackobama.com" + , _books = [ Book { _title = "An American Marriage" + , _author = "Tayari Jones" + , _amznref = "B01NCUXEFR"} + , Book { _title = "Americanah" + , _author = "Chimamanda Ngozi Adichie" + , _amznref = "B00A9ET4MC"} + ] + } + , Person { _name = "Warren Buffet" + , _pic = "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQQbmnUykS6zqgzaf44tsq1RAsnHe6H7fapEoSqUwAoJGSFKbAPSw" + , _twitter = "WarrenBuffett" + , _website = "http://berkshirehathaway.com" + , _books = [ Book { _title = "The Intelligent Investor" + , _author = "Benjamin Graham" + , _amznref = "B000FC12C8"} + , Book { _title = "Security Analysis" + , _author = "Benjamin Graham" + , _amznref = "B0037JO5J8"} + ] + } + , Person { _name = "Bill Gates" + , _pic = "https://pbs.twimg.com/profile_images/988775660163252226/XpgonN0X_400x400.jpg" + , _twitter = "BillGates" + , _website = "https://www.gatesnotes.com" + , _books = [ Book { _title = "Leonardo da Vinci" + , _author = "Walter Isaacson" + , _amznref = "1501139169" + } + , Book { _title = "Educated" + , _author = "Tara Wetsover" + , _amznref = "B072BLVM83" + } + ] + } + , Person { _name = "Stephen King" + , _pic = "https://pbs.twimg.com/profile_images/378800000836981162/b683f7509ec792c3e481ead332940cdc_400x400.jpeg" + , _twitter = "StephenKing" + , _website = "https://stephenking.com/" + , _books = [ Book { _title = "Red Moon" + , _author = "Benjamin Percy" + , _amznref = "B008TU2592" + } + , Book { _title = "The Marauders" + , _author = "Tom Cooper" + , _amznref = "B00MKZBVTM" + } + ] + } + , Person { _name = "Tobi Lütke" + , _pic = "https://pbs.twimg.com/profile_images/551403375141457920/28EOlhnM_400x400.jpeg" + , _twitter = "tobi" + , _website = "https://www.shopify.com" + , _books = [ Book { _title = "Influence" + , _author ="Robert B. Cialdini" + , _amznref = "006124189X" + } + , Book { _title = "High Output Management" + , _author ="Andrew S. Grove" + , _amznref = "B015VACHOK" + } + ] + } + , Person { _name = "Susan Cain" + , _pic = "https://pbs.twimg.com/profile_images/1474290079/SusanCain5smaller-1_400x400.jpg" + , _twitter = "susancain" + , _website = "https://www.quietrev.com" + , _books = [ Book { _title = "Bird by Bird" + , _author ="Anne Lamott" + , _amznref = "0385480016" + } + , Book { _title = "Waking Up" + , _author ="Sam Harris" + , _amznref = "1451636024" + } + ] + } + , Person { _name = "Oprah Winfrey" + , _pic = "https://pbs.twimg.com/profile_images/1013835283698049025/q5ZN4yv3_400x400.jpg" + , _twitter = "Oprah" + , _website = "http://www.oprah.com/index.html" + , _books = [ Book { _title = "A New Earth" + , _author ="Eckhart Tolle" + , _amznref = "B000PC0S5K" + } + , Book { _title = "The Poisonwood Bible" + , _author ="Barbara Kingsolver" + , _amznref = "B000QTE9WU" + } + ] + } + , Person { _name = "Patrick Collison" + , _pic = "https://pbs.twimg.com/profile_images/825622525342199809/_iAaSUQf_400x400.jpg" + , _twitter = "patrickc" + , _website = "https://patrickcollison.com" + , _books = [ Book { _title = "How Judges Think" + , _author ="Richard A. Posner" + , _amznref = "0674048067" + } + , Book { _title = "Programmers at Work" + , _author ="Susan Lammers" + , _amznref = "1556152116" + } + ] + } + , Person { _name = "Luis Von Ahn" + , _pic = "https://pbs.twimg.com/profile_images/1020343581087678464/NIXD5MdC_400x400.jpg" + , _twitter = "LuisvonAhn" + , _website = "https://www.duolingo.com/" + , _books = [ Book { _title = "Zero to One" + , _author ="Peter Thiel" + , _amznref = "B00J6YBOFQ" + } + , Book { _title = "The Hard Thing About Hard Things" + , _author ="Ben Horowitz" + , _amznref = "B00DQ845EA" + } + ] + } + , Person { _name = "Bryan Johnson" + , _pic = "https://pbs.twimg.com/profile_images/1055165076372475904/vNp60sSl_400x400.jpg" + , _twitter = "bryan_johnson" + , _website = "https://bryanjohnson.co" + , _books = [ Book { _title = "A Good Man" + , _author ="Mark Shriver" + , _amznref = "B007CLBH0M" + } + , Book { _title = "Shackleton" + , _author ="Nick Bertozzi" + , _amznref = "1596434511" + } + ] + } + , Person { _name = "Peter Thiel" + , _pic = "https://pbs.twimg.com/profile_images/1121220551/Peter_Thiel_400x400.jpg" + , _twitter = "peterthiel" + , _website = "http://zerotoonebook.com" + , _books = [ Book { _title = "Deceit, Desire, and the Novel" + , _author ="René Girard" + , _amznref = "0801818303" + } + , Book { _title = "Violence and the Sacred" + , _author ="René Girard" + , _amznref = "0801822181" + } + ] + } + , Person { _name = "Tim Ferris" + , _pic = "https://pbs.twimg.com/profile_images/49918572/half-face-ice_400x400.jpg" + , _twitter = "tferriss" + , _website = "http://tim.blog" + , _books = [ Book { _title = "10% Happier" + , _author ="Dan Harris" + , _amznref = "0062265431" + } + , Book { _title = "A Guide to the Good Life" + , _author ="William Irvine" + , _amznref = "B0040JHNQG" + } + ] + } + , Person { _name = "Allen Walton" + , _pic = "https://pbs.twimg.com/profile_images/1038905908678545409/yUbF9Ruc_400x400.jpg" + , _twitter = "allenthird" + , _website = "https://www.allenwalton.com" + , _books = [ Book { _title = "4 Hour Work Week" + , _author ="Tim Ferris" + , _amznref = "B002WE46UW" + } + , Book { _title = "Choose Yourself" + , _author ="James Altucher" + , _amznref = "B00CO8D3G4" + } + ] + } + , Person { _name = "Peter Mallouk" + , _pic = "https://pbs.twimg.com/profile_images/713172266968715264/KsyDYghf_400x400.jpg" + , _twitter = "PeterMallouk" + , _website = "https://creativeplanning.com" + , _books = [ Book { _title = "Awareness" + , _author ="Anthony de Mello SJ" + , _amznref = "B005GFBP6W" + } + , Book { _title = "The Prophet" + , _author ="Kahlil Gibran" + , _amznref = "B07NDJ3LMW" + } + ] + } + , Person { _name = "Adam Robinson" + , _pic = "https://pbs.twimg.com/profile_images/822708907051077632/y5KyboMV_400x400.jpg" + , _twitter = "IAmAdamRobinson" + , _website = "http://robinsonglobalstrategies.com" + , _books = [ Book { _title = "Wishcraft" + , _author ="Barbara Sher" + , _amznref = "0345465180" + } + , Book { _title = "You Can Be a Stock Market Genius" + , _author ="Joel Greenblatt" + , _amznref = "0684832135" + } + ] + } + , Person { _name = "Anrew Weil" + , _pic = "https://pbs.twimg.com/profile_images/987461787422359553/mpoZAmPH_400x400.jpg" + , _twitter = "DrWeil" + , _website = "https://www.drweil.com" + , _books = [ Book { _title = "The Way Of Life According To Lao Tzu" + , _author = "Witter Byner" + , _amznref = "0399512985" + } + , Book { _title = "The Psychology of Romantic Love" + , _author ="Nathaniel Branden" + , _amznref = "B0012RMVJI" + } + ] + } + , Person { _name = "Hubert Joly" + , _pic = "https://scontent-ort2-2.xx.fbcdn.net/v/t1.0-1/c1.0.193.193a/38444401_2156120597936470_9028564067043770368_n.jpg?_nc_cat=104&_nc_ht=scontent-ort2-2.xx&oh=162142edb167f389a5b585a329e4993a&oe=5CE1D578" + , _twitter = "BBYCEO" + , _website = "https://www.bestbuy.com" + , _books = [ Book { _title = "Who Says Elephants Can't Dance" + , _author = "Louis. V. Gerstner" + , _amznref = "0060523808" + } + , Book { _title = "Onward" + , _author ="Howard Schultz" + , _amznref = "1609613821" + } + ] + } + , Person { _name = "Esther Perel" + , _pic = "https://pbs.twimg.com/profile_images/1091062675151319040/MzxCcgdU_400x400.jpg" + , _twitter = "EstherPerel" + , _website = "https://www.estherperel.com" + , _books = [ Book { _title = "Crime And Punishment" + , _author = "Fyodor Dostoyevsky" + , _amznref = "B07NL94DFD" + } + , Book { _title = "If This Is a Man and The Truce" + , _author ="Primo Levi" + , _amznref = "0349100136" + } + ] + } + , Person { _name ="Neil deGrasse Tyson" + , _pic = "https://pbs.twimg.com/profile_images/74188698/NeilTysonOriginsA-Crop_400x400.jpg" + , _twitter = "neiltyson" + , _website = "https://www.haydenplanetarium.org/tyson/" + , _books = [ Book { _title = "The Prince" + , _author = "Machiavelli" + , _amznref = "B07ND3CM16" + } + , Book { _title = "The Art of War" + , _author ="Sun Tzu" + , _amznref = "1545211957" + } + ] + } + , Person { _name = "Mark Cuban" + , _pic = "https://pbs.twimg.com/profile_images/1422637130/mccigartrophy_400x400.jpg" + , _twitter = "mcuban" + , _website = "http://markcubancompanies.com/" + , _books = [ Book { _title = "The Fountainhead" + , _author = "Ayn Rend" + , _amznref = "0452273331" + } + , Book { _title = "The Gospel of Wealth " + , _author ="Andrew Carnegie" + , _amznref = "1409942171" + } + ] + } + , Person { _name = "Robert Herjavec" + , _pic = "https://pbs.twimg.com/profile_images/608643660876423170/DgxUW3eZ_400x400.jpg" + , _twitter = "robertherjavec" + , _website = "https://www.robertherjavec.com/" + , _books = [ Book { _title = "Why I Run" + , _author = "Mark Sutcliffe" + , _amznref = "B007OC9P3A" + } + , Book { _title = "Swim with the Sharks Without Being Eaten Alive" + , _author ="Harvey B. Mackay" + , _amznref = "006074281X" + } + ] + } + , Person { _name = "Caterina Fake" + , _pic = "https://pbs.twimg.com/profile_images/378800000509318185/d968d62d1bc39f2c82d3fa44db478525_400x400.jpeg" + , _twitter = "Caterina" + , _website = "https://caterina.net" + , _books = [ Book { _title = "Growth of the Soil" + , _author = "Knut Hamsun" + , _amznref = "0343181967" + } + , Book { _title = "The Thousand Autumns of Jacob de Zoet" + , _author ="David Mitchell" + , _amznref = "0812976363" + } + ] + } + , Person { _name = "Daymond John" + , _pic = "https://pbs.twimg.com/profile_images/1048022980863954944/eZvGANn0_400x400.jpg" + , _twitter = "TheSharkDaymond" + , _website = "https://daymondjohn.com/" + , _books = [ Book { _title = "Think and Grow Rich" + , _author = "Napoleon Hill" + , _amznref = "1585424331" + } + , Book { _title = "How to Win Friends & Influence People" + , _author ="Dale Carnegie" + , _amznref = "0671027034" + } + ] + } + , Person { _name = "Kevin O'Leary" + , _pic = "https://pbs.twimg.com/profile_images/1067383195597889536/cP6tNEt0_400x400.jpg" + , _twitter = "kevinolearytv" + , _website = "http://askmrwonderful.eone.libsynpro.com/" + , _books = [ Book { _title = "Competitive Advantage" + , _author = "Michael Porter" + , _amznref = "0684841460" + } + , Book { _title = "Secrets of Closing the Sale" + , _author ="Zig Ziglar" + , _amznref = "0425081028" + } + ] + } + , Person { _name = "Alex Rodriguez" + , _pic = "https://pbs.twimg.com/profile_images/796405335388848128/LbvsjCA3_400x400.jpg" + , _twitter = "AROD" + , _website = "http://www.arodcorp.com/" + , _books = [ Book { _title = "Blitzscaling" + , _author = "Reid Hoffman" + , _amznref = "1524761419" + } + , Book { _title = "Measure What Matters" + , _author ="John Doerr" + , _amznref = "0525536221" + } + ] + } + ] diff --git a/apex/Main.hs b/apex/Main.hs new file mode 100644 index 0000000..27506d8 --- /dev/null +++ b/apex/Main.hs @@ -0,0 +1,117 @@ +{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE QuasiQuotes #-} + +module Main 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| +<div .card> + <img .card-img .img-fluid src=#{_pic person}> + <div .card-body> + <h4 .card-title> + #{_name person} + <h6> + <a target=_blank href="https://twitter.com/#{_twitter person}" class="fab fa-twitter"> + <a target=_blank href=#{_website person} class="fas fa-globe"> + <p .card-text> + <ul> + $forall book <- (_books person) + <li> + <a target=_blank .text-dark href="https://www.amazon.com/dp/#{_amznref book}"> + #{_title book} +|] + +title, subtitle :: Text +title = "Influenced By Books" +subtitle = "Influential people and the books that made them." + +homepage :: [Person] -> Markup +homepage peopleList = [shamlet| +<!doctype html> +<head> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> + <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" + rel="stylesheet" + integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS" + crossorigin="anonymous"> + <link rel="stylesheet" + href="https://use.fontawesome.com/releases/v5.7.1/css/all.css" + integrity="sha384-fnmOCqbTlWIlj8LyTjo7mOUStjsKC4pOpQbqyi7RrhN7udi9RwhKkMHpvLbHG9Sr" + crossorigin="anonymous"> + <link href="/custom.css" rel="stylesheet"> + <title>#{title} | #{subtitle} + <script> + (function(f, a, t, h, o, m){ + a[h]=a[h]||function(){ + (a[h].q=a[h].q||[]).push(arguments) + }; + o=f.createElement('script'), + m=f.getElementsByTagName('script')[0]; + o.async=1; o.src=t; o.id='fathom-script'; + m.parentNode.insertBefore(o,m) + })(document, window, '//stats.simatime.com/tracker.js', 'fathom'); + fathom('set', 'siteId', 'IJATN'); + fathom('trackPageview'); +<body> + <div .container.mt-5> + <div .jumbotron> + <h1 .display-4> + #{title} + <p .lead> + #{subtitle} + + <p .lead> + <a href="http://eepurl.com/ghBFjv"> + Get new book recommendations from the world's influencers in your email. + + <div .card-columns> + $forall person <- peopleList + #{displayPerson person} +|] + +stylesheet :: ByteString +stylesheet = encodeUtf8 . renderCss $ [lucius| +.jumbotron +{ background: #fff +; text-align: center +} +h1.display-4 +{ font-family: 'Times New Roman', times, serif +} +|] undefined diff --git a/biz.cabal b/biz.cabal new file mode 100644 index 0000000..75aaf91 --- /dev/null +++ b/biz.cabal @@ -0,0 +1,30 @@ +name: ibb +version: 3 +category: Web +homepage: https://ibb.simatime.com +author: Nick Sima +maintainer: nicksima@gmail.com +copyright: 2018 Nick Sima +license: GPL-3 +license-file: LICENSE +build-type: Simple +cabal-version: >= 1.10 + +executable ibb + main-is: Main.hs + hs-source-dirs: apex + default-extensions: OverloadedStrings + ghc-options: -Wall -threaded -rtsopts -with-rtsopts=-N + other-modules: + Influencers + build-depends: + base >= 4.6 && < 5 + , blaze-html + , blaze-markup + , bytestring + , random + , random-shuffle + , scotty + , shakespeare + , text + default-language: Haskell2010 diff --git a/configuration.nix b/configuration.nix deleted file mode 100644 index 83c449b..0000000 --- a/configuration.nix +++ /dev/null @@ -1,103 +0,0 @@ -{ ... }: - -let - bensIp = "68.107.97.20"; - ibbPort = "3000"; - fathomPort = "3030"; -in -{ - nixpkgs.config.allowUnfree = true; - nixpkgs.overlays = [ - (import ./pack/default.nix) - ]; - - networking.firewall.allowedTCPPorts = [ 22 80 443 ]; - - services = { - - ibb = { - enable = true; - port = ibbPort; - }; - - fathom = { - enable = true; - port = fathomPort; - dataDir = "/var/lib/fathom"; - }; - - nginx = { - enable = true; - recommendedGzipSettings = true; - recommendedOptimisation = true; - recommendedProxySettings = true; - recommendedTlsSettings = true; - virtualHosts = { - "web.simatime.com".locations."/".proxyPass = "http://${bensIp}:8000"; - "dev.simatime.com".locations."/".proxyPass = "http://${bensIp}:${ibbPort}"; - "hero.simatime.com".locations."/".proxyPass = "http://${bensIp}:3001"; - "tv.simatime.com".locations."/".proxyPass = "http://${bensIp}:8096"; # emby runs on port 8096 - - "stats.simatime.com" = { - locations."/".proxyPass = "http://localhost:${fathomPort}"; - forceSSL = true; - enableACME = true; - }; - "influencedbybooks.com" = { - forceSSL = true; - enableACME = true; - locations = { - "/" = { - proxyPass = "http://localhost:${ibbPort}"; - }; - }; - }; - }; - }; - }; - - mailserver = { - enable = true; - monitoring = { - enable = true; - alertAddress = "ben@bsima.me"; - }; - fqdn = "mail.simatime.com"; - domains = [ "simatime.com" ]; - certificateScheme = 3; # let's encrypt - enableImap = true; - enablePop3 = true; - enableImapSsl = true; - enablePop3Ssl = true; - enableManageSieve = true; - virusScanning = false; # ur on ur own - - loginAccounts = { - "ben@simatime.com" = { - hashedPassword = "$6$Xr180W0PqprtaFB0$9S/Ug1Yz11CaWO7UdVJxQLZWfRUE3/rarB0driXkXALugEeQDLIjG2STGQBLU23//JtK3Mz8Kwsvg1/Zo0vD2/"; - aliases = [ - # admin stuff - "postmaster@simatime.com" - "abuse@simatime.com" - ]; - catchAll = [ "simatime.com" ]; - quota = "1G"; - }; - "nick@simatime.com" = { - hashedPassword = "$6$31P/Mg8k8Pezy1e$Fn1tDyssf.1EgxmLYFsQpSq6RP4wbEvP/UlBlXQhyKA9FnmFtJteXsbJM1naa8Kyylo8vZM9zmeoSthHS1slA1"; - aliases = [ - "nicolai@simatime.com" - ]; - quota = "1G"; - }; - }; - }; - - boot.cleanTmpDir = true; - networking.hostName = "simatime"; - networking.firewall.allowPing = true; - services.openssh.enable = true; - users.users.root.openssh.authorizedKeys.keys = [ - "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCiNB0iF9ClawNEizBtdYucqp1tAXXRbqvlPS6PFRrtiwSl+SJD29BCLgA5rLxcmFhBHZ/iId/En7GPFEzI/gMu071J7pUI4OcW0UVZju3GNc6ZEz/a6AD2u79JiXEDHfPEdmMqAe36kkaK0KJWSQP3xsFRwJ+8F8HHbSwoCLL+GJhBgAWHQLGfKesNrDacNljNDU3CgkEnDmu8QKuSzH2k1vrr69q2u2iMSAdiStDBAWEjN5nCVrm2XB2vmFLMtXpX2n8JI+znOGzRRDc8dNXejQeDMZGyV6jfVidEIX7vdgSydGjTRKcCLVAsKY3z0gYBZ8u8EUNujgcFBnnAvytj ben@neb" - ]; -} diff --git a/depo/nutin-madaj/configuration.nix b/depo/nutin-madaj/configuration.nix new file mode 100644 index 0000000..a6d303d --- /dev/null +++ b/depo/nutin-madaj/configuration.nix @@ -0,0 +1,103 @@ +{ ... }: + +let + bensIp = "68.107.97.20"; + ibbPort = "3000"; + fathomPort = "3030"; +in +{ + nixpkgs.config.allowUnfree = true; + nixpkgs.overlays = [ + (import ../../pack/default.nix) + ]; + + networking.firewall.allowedTCPPorts = [ 22 80 443 ]; + + services = { + + ibb = { + enable = true; + port = ibbPort; + }; + + fathom = { + enable = true; + port = fathomPort; + dataDir = "/var/lib/fathom"; + }; + + nginx = { + enable = true; + recommendedGzipSettings = true; + recommendedOptimisation = true; + recommendedProxySettings = true; + recommendedTlsSettings = true; + virtualHosts = { + "web.simatime.com".locations."/".proxyPass = "http://${bensIp}:8000"; + "dev.simatime.com".locations."/".proxyPass = "http://${bensIp}:${ibbPort}"; + "hero.simatime.com".locations."/".proxyPass = "http://${bensIp}:3001"; + "tv.simatime.com".locations."/".proxyPass = "http://${bensIp}:8096"; # emby runs on port 8096 + + "stats.simatime.com" = { + locations."/".proxyPass = "http://localhost:${fathomPort}"; + forceSSL = true; + enableACME = true; + }; + "influencedbybooks.com" = { + forceSSL = true; + enableACME = true; + locations = { + "/" = { + proxyPass = "http://localhost:${ibbPort}"; + }; + }; + }; + }; + }; + }; + + mailserver = { + enable = true; + monitoring = { + enable = true; + alertAddress = "ben@bsima.me"; + }; + fqdn = "mail.simatime.com"; + domains = [ "simatime.com" ]; + certificateScheme = 3; # let's encrypt + enableImap = true; + enablePop3 = true; + enableImapSsl = true; + enablePop3Ssl = true; + enableManageSieve = true; + virusScanning = false; # ur on ur own + + loginAccounts = { + "ben@simatime.com" = { + hashedPassword = "$6$Xr180W0PqprtaFB0$9S/Ug1Yz11CaWO7UdVJxQLZWfRUE3/rarB0driXkXALugEeQDLIjG2STGQBLU23//JtK3Mz8Kwsvg1/Zo0vD2/"; + aliases = [ + # admin stuff + "postmaster@simatime.com" + "abuse@simatime.com" + ]; + catchAll = [ "simatime.com" ]; + quota = "1G"; + }; + "nick@simatime.com" = { + hashedPassword = "$6$31P/Mg8k8Pezy1e$Fn1tDyssf.1EgxmLYFsQpSq6RP4wbEvP/UlBlXQhyKA9FnmFtJteXsbJM1naa8Kyylo8vZM9zmeoSthHS1slA1"; + aliases = [ + "nicolai@simatime.com" + ]; + quota = "1G"; + }; + }; + }; + + boot.cleanTmpDir = true; + networking.hostName = "simatime"; + networking.firewall.allowPing = true; + services.openssh.enable = true; + users.users.root.openssh.authorizedKeys.keys = [ + "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCiNB0iF9ClawNEizBtdYucqp1tAXXRbqvlPS6PFRrtiwSl+SJD29BCLgA5rLxcmFhBHZ/iId/En7GPFEzI/gMu071J7pUI4OcW0UVZju3GNc6ZEz/a6AD2u79JiXEDHfPEdmMqAe36kkaK0KJWSQP3xsFRwJ+8F8HHbSwoCLL+GJhBgAWHQLGfKesNrDacNljNDU3CgkEnDmu8QKuSzH2k1vrr69q2u2iMSAdiStDBAWEjN5nCVrm2XB2vmFLMtXpX2n8JI+znOGzRRDc8dNXejQeDMZGyV6jfVidEIX7vdgSydGjTRKcCLVAsKY3z0gYBZ8u8EUNujgcFBnnAvytj ben@neb" + ]; +} diff --git a/depo/nutin-madaj/default.nix b/depo/nutin-madaj/default.nix new file mode 100644 index 0000000..a97a4a7 --- /dev/null +++ b/depo/nutin-madaj/default.nix @@ -0,0 +1,25 @@ +let + nixpkgs = builtins.fetchTarball (import ../../pack/nixpkgs.nix); +in +import "${nixpkgs}/nixos" { + system = "x86_64-linux"; + configuration = { + imports = [ + ./hardware-configuration.nix + ./networking.nix + + # end config + ./configuration.nix + + # our modules + ../../mode/ibb.nix + ../../mode/fathom.nix + + # third party + (builtins.fetchTarball { + url = "https://gitlab.com/simple-nixos-mailserver/nixos-mailserver/-/archive/v2.2.0/nixos-mailserver-v2.2.0.tar.gz"; + sha256 = "0gqzgy50hgb5zmdjiffaqp277a68564vflfpjvk1gv6079zahksc"; + }) + ]; + }; +} diff --git a/depo/nutin-madaj/hardware-configuration.nix b/depo/nutin-madaj/hardware-configuration.nix new file mode 100644 index 0000000..8c88cb7 --- /dev/null +++ b/depo/nutin-madaj/hardware-configuration.nix @@ -0,0 +1,6 @@ +{ ... }: +{ + imports = [ <nixpkgs/nixos/modules/profiles/qemu-guest.nix> ]; + boot.loader.grub.device = "/dev/vda"; + fileSystems."/" = { device = "/dev/vda1"; fsType = "ext4"; }; +} diff --git a/depo/nutin-madaj/networking.nix b/depo/nutin-madaj/networking.nix new file mode 100644 index 0000000..6c55005 --- /dev/null +++ b/depo/nutin-madaj/networking.nix @@ -0,0 +1,30 @@ +{ lib, ... }: { + # This file was populated at runtime with the networking + # details gathered from the active system. + networking = { + nameservers = [ + "67.207.67.2" + "67.207.67.3" + ]; + defaultGateway = "159.89.128.1"; + defaultGateway6 = ""; + dhcpcd.enable = false; + usePredictableInterfaceNames = lib.mkForce true; + interfaces = { + eth0 = { + ipv4.addresses = [ + { address="159.89.128.69"; prefixLength=20; } +{ address="10.46.0.6"; prefixLength=16; } + ]; + ipv6.addresses = [ + { address="fe80::e899:c0ff:fe9c:e194"; prefixLength=64; } + ]; + }; + + }; + }; + services.udev.extraRules = '' + ATTR{address}=="ea:99:c0:9c:e1:94", NAME="eth0" + + ''; +} diff --git a/hardware-configuration.nix b/hardware-configuration.nix deleted file mode 100644 index 8c88cb7..0000000 --- a/hardware-configuration.nix +++ /dev/null @@ -1,6 +0,0 @@ -{ ... }: -{ - imports = [ <nixpkgs/nixos/modules/profiles/qemu-guest.nix> ]; - boot.loader.grub.device = "/dev/vda"; - fileSystems."/" = { device = "/dev/vda1"; fsType = "ext4"; }; -} diff --git a/ibb/Influencers.hs b/ibb/Influencers.hs deleted file mode 100644 index 7a7031f..0000000 --- a/ibb/Influencers.hs +++ /dev/null @@ -1,393 +0,0 @@ -{-# LANGUAGE OverloadedStrings #-} -{-# LANGUAGE QuasiQuotes #-} - -module Influencers where - -import Data.Text.Lazy (Text) - -data Person = Person - { _name :: Text - , _pic :: Text - , _twitter :: Text - , _website :: Text - , _books :: [Book] - } - -data Book = Book - { _title :: Text - , _author :: Text - , _amznref :: Text - } - -allPeople :: [Person] -allPeople = - [ Person { _name = "Joe Rogan" - , _pic = "https://pbs.twimg.com/profile_images/552307347851210752/vrXDcTFC_400x400.jpeg" - , _twitter = "joerogan" - , _website = "http://joerogan.com" - , _books = [ Book {_title = "Food of the Gods" - , _author = "Terence McKenna" - , _amznref = "0553371304" - } - , Book { _title = "The War of Art" - , _author ="Steven Pressfield" - , _amznref ="B007A4SDCG" - } - ] - } - , Person { _name = "Beyoncé" - , _pic = "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTxT84sF19lxdnSiblIXAp-Y4wAigpQn8sZ2GtAerIR_ApiiEJfFQ" - , _twitter = "Beyonce" - , _website = "http://beyonce.com" - , _books = [ Book { _title = "What Will It Take To Make A Woman President?" - , _author = "Marianne Schnall" - , _amznref = "B00E257Y7G"} - ] - } - , Person { _name = "Barrack Obama" - , _pic = "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQeLzftR36p0hYI-EKNa5fm7CYDuN-vyz23_R48ocqa8X1nPr6C" - , _twitter = "BarackObama" - , _website = "http://barackobama.com" - , _books = [ Book { _title = "An American Marriage" - , _author = "Tayari Jones" - , _amznref = "B01NCUXEFR"} - , Book { _title = "Americanah" - , _author = "Chimamanda Ngozi Adichie" - , _amznref = "B00A9ET4MC"} - ] - } - , Person { _name = "Warren Buffet" - , _pic = "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQQbmnUykS6zqgzaf44tsq1RAsnHe6H7fapEoSqUwAoJGSFKbAPSw" - , _twitter = "WarrenBuffett" - , _website = "http://berkshirehathaway.com" - , _books = [ Book { _title = "The Intelligent Investor" - , _author = "Benjamin Graham" - , _amznref = "B000FC12C8"} - , Book { _title = "Security Analysis" - , _author = "Benjamin Graham" - , _amznref = "B0037JO5J8"} - ] - } - , Person { _name = "Bill Gates" - , _pic = "https://pbs.twimg.com/profile_images/988775660163252226/XpgonN0X_400x400.jpg" - , _twitter = "BillGates" - , _website = "https://www.gatesnotes.com" - , _books = [ Book { _title = "Leonardo da Vinci" - , _author = "Walter Isaacson" - , _amznref = "1501139169" - } - , Book { _title = "Educated" - , _author = "Tara Wetsover" - , _amznref = "B072BLVM83" - } - ] - } - , Person { _name = "Stephen King" - , _pic = "https://pbs.twimg.com/profile_images/378800000836981162/b683f7509ec792c3e481ead332940cdc_400x400.jpeg" - , _twitter = "StephenKing" - , _website = "https://stephenking.com/" - , _books = [ Book { _title = "Red Moon" - , _author = "Benjamin Percy" - , _amznref = "B008TU2592" - } - , Book { _title = "The Marauders" - , _author = "Tom Cooper" - , _amznref = "B00MKZBVTM" - } - ] - } - , Person { _name = "Tobi Lütke" - , _pic = "https://pbs.twimg.com/profile_images/551403375141457920/28EOlhnM_400x400.jpeg" - , _twitter = "tobi" - , _website = "https://www.shopify.com" - , _books = [ Book { _title = "Influence" - , _author ="Robert B. Cialdini" - , _amznref = "006124189X" - } - , Book { _title = "High Output Management" - , _author ="Andrew S. Grove" - , _amznref = "B015VACHOK" - } - ] - } - , Person { _name = "Susan Cain" - , _pic = "https://pbs.twimg.com/profile_images/1474290079/SusanCain5smaller-1_400x400.jpg" - , _twitter = "susancain" - , _website = "https://www.quietrev.com" - , _books = [ Book { _title = "Bird by Bird" - , _author ="Anne Lamott" - , _amznref = "0385480016" - } - , Book { _title = "Waking Up" - , _author ="Sam Harris" - , _amznref = "1451636024" - } - ] - } - , Person { _name = "Oprah Winfrey" - , _pic = "https://pbs.twimg.com/profile_images/1013835283698049025/q5ZN4yv3_400x400.jpg" - , _twitter = "Oprah" - , _website = "http://www.oprah.com/index.html" - , _books = [ Book { _title = "A New Earth" - , _author ="Eckhart Tolle" - , _amznref = "B000PC0S5K" - } - , Book { _title = "The Poisonwood Bible" - , _author ="Barbara Kingsolver" - , _amznref = "B000QTE9WU" - } - ] - } - , Person { _name = "Patrick Collison" - , _pic = "https://pbs.twimg.com/profile_images/825622525342199809/_iAaSUQf_400x400.jpg" - , _twitter = "patrickc" - , _website = "https://patrickcollison.com" - , _books = [ Book { _title = "How Judges Think" - , _author ="Richard A. Posner" - , _amznref = "0674048067" - } - , Book { _title = "Programmers at Work" - , _author ="Susan Lammers" - , _amznref = "1556152116" - } - ] - } - , Person { _name = "Luis Von Ahn" - , _pic = "https://pbs.twimg.com/profile_images/1020343581087678464/NIXD5MdC_400x400.jpg" - , _twitter = "LuisvonAhn" - , _website = "https://www.duolingo.com/" - , _books = [ Book { _title = "Zero to One" - , _author ="Peter Thiel" - , _amznref = "B00J6YBOFQ" - } - , Book { _title = "The Hard Thing About Hard Things" - , _author ="Ben Horowitz" - , _amznref = "B00DQ845EA" - } - ] - } - , Person { _name = "Bryan Johnson" - , _pic = "https://pbs.twimg.com/profile_images/1055165076372475904/vNp60sSl_400x400.jpg" - , _twitter = "bryan_johnson" - , _website = "https://bryanjohnson.co" - , _books = [ Book { _title = "A Good Man" - , _author ="Mark Shriver" - , _amznref = "B007CLBH0M" - } - , Book { _title = "Shackleton" - , _author ="Nick Bertozzi" - , _amznref = "1596434511" - } - ] - } - , Person { _name = "Peter Thiel" - , _pic = "https://pbs.twimg.com/profile_images/1121220551/Peter_Thiel_400x400.jpg" - , _twitter = "peterthiel" - , _website = "http://zerotoonebook.com" - , _books = [ Book { _title = "Deceit, Desire, and the Novel" - , _author ="René Girard" - , _amznref = "0801818303" - } - , Book { _title = "Violence and the Sacred" - , _author ="René Girard" - , _amznref = "0801822181" - } - ] - } - , Person { _name = "Tim Ferris" - , _pic = "https://pbs.twimg.com/profile_images/49918572/half-face-ice_400x400.jpg" - , _twitter = "tferriss" - , _website = "http://tim.blog" - , _books = [ Book { _title = "10% Happier" - , _author ="Dan Harris" - , _amznref = "0062265431" - } - , Book { _title = "A Guide to the Good Life" - , _author ="William Irvine" - , _amznref = "B0040JHNQG" - } - ] - } - , Person { _name = "Allen Walton" - , _pic = "https://pbs.twimg.com/profile_images/1038905908678545409/yUbF9Ruc_400x400.jpg" - , _twitter = "allenthird" - , _website = "https://www.allenwalton.com" - , _books = [ Book { _title = "4 Hour Work Week" - , _author ="Tim Ferris" - , _amznref = "B002WE46UW" - } - , Book { _title = "Choose Yourself" - , _author ="James Altucher" - , _amznref = "B00CO8D3G4" - } - ] - } - , Person { _name = "Peter Mallouk" - , _pic = "https://pbs.twimg.com/profile_images/713172266968715264/KsyDYghf_400x400.jpg" - , _twitter = "PeterMallouk" - , _website = "https://creativeplanning.com" - , _books = [ Book { _title = "Awareness" - , _author ="Anthony de Mello SJ" - , _amznref = "B005GFBP6W" - } - , Book { _title = "The Prophet" - , _author ="Kahlil Gibran" - , _amznref = "B07NDJ3LMW" - } - ] - } - , Person { _name = "Adam Robinson" - , _pic = "https://pbs.twimg.com/profile_images/822708907051077632/y5KyboMV_400x400.jpg" - , _twitter = "IAmAdamRobinson" - , _website = "http://robinsonglobalstrategies.com" - , _books = [ Book { _title = "Wishcraft" - , _author ="Barbara Sher" - , _amznref = "0345465180" - } - , Book { _title = "You Can Be a Stock Market Genius" - , _author ="Joel Greenblatt" - , _amznref = "0684832135" - } - ] - } - , Person { _name = "Anrew Weil" - , _pic = "https://pbs.twimg.com/profile_images/987461787422359553/mpoZAmPH_400x400.jpg" - , _twitter = "DrWeil" - , _website = "https://www.drweil.com" - , _books = [ Book { _title = "The Way Of Life According To Lao Tzu" - , _author = "Witter Byner" - , _amznref = "0399512985" - } - , Book { _title = "The Psychology of Romantic Love" - , _author ="Nathaniel Branden" - , _amznref = "B0012RMVJI" - } - ] - } - , Person { _name = "Hubert Joly" - , _pic = "https://scontent-ort2-2.xx.fbcdn.net/v/t1.0-1/c1.0.193.193a/38444401_2156120597936470_9028564067043770368_n.jpg?_nc_cat=104&_nc_ht=scontent-ort2-2.xx&oh=162142edb167f389a5b585a329e4993a&oe=5CE1D578" - , _twitter = "BBYCEO" - , _website = "https://www.bestbuy.com" - , _books = [ Book { _title = "Who Says Elephants Can't Dance" - , _author = "Louis. V. Gerstner" - , _amznref = "0060523808" - } - , Book { _title = "Onward" - , _author ="Howard Schultz" - , _amznref = "1609613821" - } - ] - } - , Person { _name = "Esther Perel" - , _pic = "https://pbs.twimg.com/profile_images/1091062675151319040/MzxCcgdU_400x400.jpg" - , _twitter = "EstherPerel" - , _website = "https://www.estherperel.com" - , _books = [ Book { _title = "Crime And Punishment" - , _author = "Fyodor Dostoyevsky" - , _amznref = "B07NL94DFD" - } - , Book { _title = "If This Is a Man and The Truce" - , _author ="Primo Levi" - , _amznref = "0349100136" - } - ] - } - , Person { _name ="Neil deGrasse Tyson" - , _pic = "https://pbs.twimg.com/profile_images/74188698/NeilTysonOriginsA-Crop_400x400.jpg" - , _twitter = "neiltyson" - , _website = "https://www.haydenplanetarium.org/tyson/" - , _books = [ Book { _title = "The Prince" - , _author = "Machiavelli" - , _amznref = "B07ND3CM16" - } - , Book { _title = "The Art of War" - , _author ="Sun Tzu" - , _amznref = "1545211957" - } - ] - } - , Person { _name = "Mark Cuban" - , _pic = "https://pbs.twimg.com/profile_images/1422637130/mccigartrophy_400x400.jpg" - , _twitter = "mcuban" - , _website = "http://markcubancompanies.com/" - , _books = [ Book { _title = "The Fountainhead" - , _author = "Ayn Rend" - , _amznref = "0452273331" - } - , Book { _title = "The Gospel of Wealth " - , _author ="Andrew Carnegie" - , _amznref = "1409942171" - } - ] - } - , Person { _name = "Robert Herjavec" - , _pic = "https://pbs.twimg.com/profile_images/608643660876423170/DgxUW3eZ_400x400.jpg" - , _twitter = "robertherjavec" - , _website = "https://www.robertherjavec.com/" - , _books = [ Book { _title = "Why I Run" - , _author = "Mark Sutcliffe" - , _amznref = "B007OC9P3A" - } - , Book { _title = "Swim with the Sharks Without Being Eaten Alive" - , _author ="Harvey B. Mackay" - , _amznref = "006074281X" - } - ] - } - , Person { _name = "Caterina Fake" - , _pic = "https://pbs.twimg.com/profile_images/378800000509318185/d968d62d1bc39f2c82d3fa44db478525_400x400.jpeg" - , _twitter = "Caterina" - , _website = "https://caterina.net" - , _books = [ Book { _title = "Growth of the Soil" - , _author = "Knut Hamsun" - , _amznref = "0343181967" - } - , Book { _title = "The Thousand Autumns of Jacob de Zoet" - , _author ="David Mitchell" - , _amznref = "0812976363" - } - ] - } - , Person { _name = "Daymond John" - , _pic = "https://pbs.twimg.com/profile_images/1048022980863954944/eZvGANn0_400x400.jpg" - , _twitter = "TheSharkDaymond" - , _website = "https://daymondjohn.com/" - , _books = [ Book { _title = "Think and Grow Rich" - , _author = "Napoleon Hill" - , _amznref = "1585424331" - } - , Book { _title = "How to Win Friends & Influence People" - , _author ="Dale Carnegie" - , _amznref = "0671027034" - } - ] - } - , Person { _name = "Kevin O'Leary" - , _pic = "https://pbs.twimg.com/profile_images/1067383195597889536/cP6tNEt0_400x400.jpg" - , _twitter = "kevinolearytv" - , _website = "http://askmrwonderful.eone.libsynpro.com/" - , _books = [ Book { _title = "Competitive Advantage" - , _author = "Michael Porter" - , _amznref = "0684841460" - } - , Book { _title = "Secrets of Closing the Sale" - , _author ="Zig Ziglar" - , _amznref = "0425081028" - } - ] - } - , Person { _name = "Alex Rodriguez" - , _pic = "https://pbs.twimg.com/profile_images/796405335388848128/LbvsjCA3_400x400.jpg" - , _twitter = "AROD" - , _website = "http://www.arodcorp.com/" - , _books = [ Book { _title = "Blitzscaling" - , _author = "Reid Hoffman" - , _amznref = "1524761419" - } - , Book { _title = "Measure What Matters" - , _author ="John Doerr" - , _amznref = "0525536221" - } - ] - } - ] diff --git a/ibb/LICENSE b/ibb/LICENSE deleted file mode 100644 index 1d1026a..0000000 --- a/ibb/LICENSE +++ /dev/null @@ -1 +0,0 @@ -All rights reserved. \ No newline at end of file diff --git a/ibb/Main.hs b/ibb/Main.hs deleted file mode 100644 index 27506d8..0000000 --- a/ibb/Main.hs +++ /dev/null @@ -1,117 +0,0 @@ -{-# LANGUAGE OverloadedStrings #-} -{-# LANGUAGE QuasiQuotes #-} - -module Main 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| -<div .card> - <img .card-img .img-fluid src=#{_pic person}> - <div .card-body> - <h4 .card-title> - #{_name person} - <h6> - <a target=_blank href="https://twitter.com/#{_twitter person}" class="fab fa-twitter"> - <a target=_blank href=#{_website person} class="fas fa-globe"> - <p .card-text> - <ul> - $forall book <- (_books person) - <li> - <a target=_blank .text-dark href="https://www.amazon.com/dp/#{_amznref book}"> - #{_title book} -|] - -title, subtitle :: Text -title = "Influenced By Books" -subtitle = "Influential people and the books that made them." - -homepage :: [Person] -> Markup -homepage peopleList = [shamlet| -<!doctype html> -<head> - <meta charset="utf-8"> - <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> - <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" - rel="stylesheet" - integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS" - crossorigin="anonymous"> - <link rel="stylesheet" - href="https://use.fontawesome.com/releases/v5.7.1/css/all.css" - integrity="sha384-fnmOCqbTlWIlj8LyTjo7mOUStjsKC4pOpQbqyi7RrhN7udi9RwhKkMHpvLbHG9Sr" - crossorigin="anonymous"> - <link href="/custom.css" rel="stylesheet"> - <title>#{title} | #{subtitle} - <script> - (function(f, a, t, h, o, m){ - a[h]=a[h]||function(){ - (a[h].q=a[h].q||[]).push(arguments) - }; - o=f.createElement('script'), - m=f.getElementsByTagName('script')[0]; - o.async=1; o.src=t; o.id='fathom-script'; - m.parentNode.insertBefore(o,m) - })(document, window, '//stats.simatime.com/tracker.js', 'fathom'); - fathom('set', 'siteId', 'IJATN'); - fathom('trackPageview'); -<body> - <div .container.mt-5> - <div .jumbotron> - <h1 .display-4> - #{title} - <p .lead> - #{subtitle} - - <p .lead> - <a href="http://eepurl.com/ghBFjv"> - Get new book recommendations from the world's influencers in your email. - - <div .card-columns> - $forall person <- peopleList - #{displayPerson person} -|] - -stylesheet :: ByteString -stylesheet = encodeUtf8 . renderCss $ [lucius| -.jumbotron -{ background: #fff -; text-align: center -} -h1.display-4 -{ font-family: 'Times New Roman', times, serif -} -|] undefined diff --git a/ibb/default.nix b/ibb/default.nix deleted file mode 100644 index 8525d99..0000000 --- a/ibb/default.nix +++ /dev/null @@ -1,23 +0,0 @@ -{ compiler ? "ghc843" -, doHaddock ? false -, doBenchmark ? false -, doCheck ? true -, withHoogle ? false -, nixpkgs ? builtins.fetchTarball (import ../pack/nixpkgs.nix) -}: - -with import "${nixpkgs}" {}; - -haskell.packages.${compiler}.developPackage { - root = ./.; - overrides = with haskell.lib; self: super: { - ghc = - if withHoogle - then super.ghc // {withPackages = super.ghc.withHoogle;} - else super.ghc; - ghcWithPackages = - if withHoogle - then self.ghc.withPackages - else super.ghcWithPackages; - }; -} diff --git a/ibb/ibb.cabal b/ibb/ibb.cabal deleted file mode 100644 index 4d8ebc7..0000000 --- a/ibb/ibb.cabal +++ /dev/null @@ -1,30 +0,0 @@ -name: ibb -version: 3 -category: Web -homepage: https://ibb.simatime.com -author: Nick Sima -maintainer: nicksima@gmail.com -copyright: 2018 Nick Sima -license: GPL-3 -license-file: LICENSE -build-type: Simple -cabal-version: >= 1.10 - -executable ibb - main-is: Main.hs - hs-source-dirs: . - default-extensions: OverloadedStrings - ghc-options: -Wall -threaded -rtsopts -with-rtsopts=-N - other-modules: - Influencers - build-depends: - base >= 4.6 && < 5 - , blaze-html - , blaze-markup - , bytestring - , random - , random-shuffle - , scotty - , shakespeare - , text - default-language: Haskell2010 diff --git a/mode/fathom.nix b/mode/fathom.nix new file mode 100644 index 0000000..dee34b9 --- /dev/null +++ b/mode/fathom.nix @@ -0,0 +1,93 @@ +{ options +, lib +, config +, pkgs +, modulesPath +}: + +with lib; + +let + cfg = config.services.fathom; +in +{ + options.services.fathom = { + enable = lib.mkEnableOption "Enable the Fathom Analytics service"; + + port = mkOption { + type = types.string; + default = "3000"; + description = '' + The port on which Fathom will listen for + incoming HTTP traffic. + ''; + }; + + gzip = mkOption { + type = types.bool; + default = true; + description = "Whether or not to enable gzip compression."; + }; + + debug = mkOption { + type = types.bool; + default = false; + description = "Whether or not to enable debug mode."; + }; + + dataDir = mkOption { + type = types.path; + default = "/var/lib/fathom"; + description = "Fathom data directory"; + }; + }; + + config = mkIf cfg.enable { + systemd.services.fathom = { + wantedBy = [ "multi-user.target" ]; + after = [ "network.target" ]; + + environment = { + FATHOM_SERVER_ADDR = cfg.port; + FATHOM_GZIP = builtins.toString cfg.gzip; + FATHOM_DEBUG = builtins.toString cfg.debug; + FATHOM_DATABASE_DRIVER = "sqlite3"; + FATHOM_DATABASE_NAME = "${cfg.dataDir}/fathom.db"; + FATHOM_SECRET = "random-secret-string"; + }; + preStart = '' + echo "[fathom] creating ${cfg.dataDir}" + mkdir -p ${cfg.dataDir} + chown -R fathom:fathom ${cfg.dataDir} + echo "[fathom]" creating ${cfg.dataDir}/.env + env | grep "^FATHOM" > ${cfg.dataDir}/.env + ''; + description = '' + Fathom Analytics + ''; + + serviceConfig = { + Type = "simple"; + User = "fathom"; + Group = "fathom"; + ExecStart = "${pkgs.fathom}/bin/fathom server"; + KillSignal = "INT"; + WorkingDirectory = cfg.dataDir; + Restart = "on-failure"; + RestartSec = "10"; + PermissionsStartOnly = "true"; + }; + }; + + environment.systemPackages = [ pkgs.fathom ]; + + users = { + groups = { fathom = {}; }; + users.fathom = { + description = "Fathom daemon user"; + home = cfg.dataDir; + group = "fathom"; + }; + }; + }; +} diff --git a/mode/ibb.nix b/mode/ibb.nix new file mode 100644 index 0000000..e2d4dd0 --- /dev/null +++ b/mode/ibb.nix @@ -0,0 +1,42 @@ +{ options +, lib +, config +, pkgs +, modulesPath +}: + +let + cfg = config.services.ibb; +in +{ + options.services.ibb = { + enable = lib.mkEnableOption "Enable the IBB service"; + port = lib.mkOption { + type = lib.types.string; + default = "3000"; + description = '' + The port on which IBB will listen for + incoming HTTP traffic. + ''; + }; + }; + config = lib.mkIf cfg.enable { + systemd.services.ibb = { + path = with pkgs; [ ibb bash ]; + wantedBy = [ "multi-user.target" ]; + script = '' + PORT=${cfg.port} ./bin/ibb + ''; + description = '' + Influenced By Books website + ''; + serviceConfig = { + WorkingDirectory=pkgs.ibb; + KillSignal="INT"; + Type = "simple"; + Restart = "on-abort"; + RestartSec = "10"; + }; + }; + }; +} diff --git a/modules/fathom.nix b/modules/fathom.nix deleted file mode 100644 index dee34b9..0000000 --- a/modules/fathom.nix +++ /dev/null @@ -1,93 +0,0 @@ -{ options -, lib -, config -, pkgs -, modulesPath -}: - -with lib; - -let - cfg = config.services.fathom; -in -{ - options.services.fathom = { - enable = lib.mkEnableOption "Enable the Fathom Analytics service"; - - port = mkOption { - type = types.string; - default = "3000"; - description = '' - The port on which Fathom will listen for - incoming HTTP traffic. - ''; - }; - - gzip = mkOption { - type = types.bool; - default = true; - description = "Whether or not to enable gzip compression."; - }; - - debug = mkOption { - type = types.bool; - default = false; - description = "Whether or not to enable debug mode."; - }; - - dataDir = mkOption { - type = types.path; - default = "/var/lib/fathom"; - description = "Fathom data directory"; - }; - }; - - config = mkIf cfg.enable { - systemd.services.fathom = { - wantedBy = [ "multi-user.target" ]; - after = [ "network.target" ]; - - environment = { - FATHOM_SERVER_ADDR = cfg.port; - FATHOM_GZIP = builtins.toString cfg.gzip; - FATHOM_DEBUG = builtins.toString cfg.debug; - FATHOM_DATABASE_DRIVER = "sqlite3"; - FATHOM_DATABASE_NAME = "${cfg.dataDir}/fathom.db"; - FATHOM_SECRET = "random-secret-string"; - }; - preStart = '' - echo "[fathom] creating ${cfg.dataDir}" - mkdir -p ${cfg.dataDir} - chown -R fathom:fathom ${cfg.dataDir} - echo "[fathom]" creating ${cfg.dataDir}/.env - env | grep "^FATHOM" > ${cfg.dataDir}/.env - ''; - description = '' - Fathom Analytics - ''; - - serviceConfig = { - Type = "simple"; - User = "fathom"; - Group = "fathom"; - ExecStart = "${pkgs.fathom}/bin/fathom server"; - KillSignal = "INT"; - WorkingDirectory = cfg.dataDir; - Restart = "on-failure"; - RestartSec = "10"; - PermissionsStartOnly = "true"; - }; - }; - - environment.systemPackages = [ pkgs.fathom ]; - - users = { - groups = { fathom = {}; }; - users.fathom = { - description = "Fathom daemon user"; - home = cfg.dataDir; - group = "fathom"; - }; - }; - }; -} diff --git a/modules/ibb.nix b/modules/ibb.nix deleted file mode 100644 index e2d4dd0..0000000 --- a/modules/ibb.nix +++ /dev/null @@ -1,42 +0,0 @@ -{ options -, lib -, config -, pkgs -, modulesPath -}: - -let - cfg = config.services.ibb; -in -{ - options.services.ibb = { - enable = lib.mkEnableOption "Enable the IBB service"; - port = lib.mkOption { - type = lib.types.string; - default = "3000"; - description = '' - The port on which IBB will listen for - incoming HTTP traffic. - ''; - }; - }; - config = lib.mkIf cfg.enable { - systemd.services.ibb = { - path = with pkgs; [ ibb bash ]; - wantedBy = [ "multi-user.target" ]; - script = '' - PORT=${cfg.port} ./bin/ibb - ''; - description = '' - Influenced By Books website - ''; - serviceConfig = { - WorkingDirectory=pkgs.ibb; - KillSignal="INT"; - Type = "simple"; - Restart = "on-abort"; - RestartSec = "10"; - }; - }; - }; -} diff --git a/networking.nix b/networking.nix deleted file mode 100644 index 6c55005..0000000 --- a/networking.nix +++ /dev/null @@ -1,30 +0,0 @@ -{ lib, ... }: { - # This file was populated at runtime with the networking - # details gathered from the active system. - networking = { - nameservers = [ - "67.207.67.2" - "67.207.67.3" - ]; - defaultGateway = "159.89.128.1"; - defaultGateway6 = ""; - dhcpcd.enable = false; - usePredictableInterfaceNames = lib.mkForce true; - interfaces = { - eth0 = { - ipv4.addresses = [ - { address="159.89.128.69"; prefixLength=20; } -{ address="10.46.0.6"; prefixLength=16; } - ]; - ipv6.addresses = [ - { address="fe80::e899:c0ff:fe9c:e194"; prefixLength=64; } - ]; - }; - - }; - }; - services.udev.extraRules = '' - ATTR{address}=="ea:99:c0:9c:e1:94", NAME="eth0" - - ''; -} diff --git a/nixos.nix b/nixos.nix deleted file mode 100644 index ea1605a..0000000 --- a/nixos.nix +++ /dev/null @@ -1,27 +0,0 @@ -# Nix config for the main biz machine. - -let - nixpkgs = builtins.fetchTarball (import ./pack/nixpkgs.nix); -in -import "${nixpkgs}/nixos" { - system = "x86_64-linux"; - configuration = { - imports = [ - ./hardware-configuration.nix - ./networking.nix - - # end config - ./configuration.nix - - # our modules - ./modules/ibb.nix - ./modules/fathom.nix - - # third party - (builtins.fetchTarball { - url = "https://gitlab.com/simple-nixos-mailserver/nixos-mailserver/-/archive/v2.2.0/nixos-mailserver-v2.2.0.tar.gz"; - sha256 = "0gqzgy50hgb5zmdjiffaqp277a68564vflfpjvk1gv6079zahksc"; - }) - ]; - }; -} diff --git a/pack/default.nix b/pack/default.nix index 6c218bb..255db4c 100644 --- a/pack/default.nix +++ b/pack/default.nix @@ -2,5 +2,5 @@ self: super: { fathom = import ./fathom.nix { nixpkgs = super; }; - ibb = import ../ibb/default.nix { }; + ibb = import ./ibb.nix { }; } diff --git a/pack/ibb.nix b/pack/ibb.nix new file mode 100644 index 0000000..ba4cae7 --- /dev/null +++ b/pack/ibb.nix @@ -0,0 +1,23 @@ +{ compiler ? "ghc843" +, doHaddock ? false +, doBenchmark ? false +, doCheck ? true +, withHoogle ? false +, nixpkgs ? builtins.fetchTarball (import ./nixpkgs.nix) +}: + +with import "${nixpkgs}" {}; + +haskell.packages.${compiler}.developPackage { + root = ../.; + overrides = with haskell.lib; self: super: { + ghc = + if withHoogle + then super.ghc // {withPackages = super.ghc.withHoogle;} + else super.ghc; + ghcWithPackages = + if withHoogle + then self.ghc.withPackages + else super.ghcWithPackages; + }; +} -- cgit v1.2.3