initial commit

This commit is contained in:
2021-08-05 10:48:00 +02:00
commit da4d094689
16 changed files with 5453 additions and 0 deletions

30
server/app/Main.hs Normal file
View File

@@ -0,0 +1,30 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
module Main where
import Data.Semigroup ((<>))
import Network.Wai.Application.Static
import Network.Wai.Handler.Warp
import Options.Applicative
import System.FilePath
import WaiAppStatic.Types
import Data.Maybe
data Config = Config
{ location :: FilePath,
port :: Int
}
configP :: Parser Config
configP =
let location = strArgument (metavar "PATH" <> help "Directory to serve")
port = argument auto (metavar "PORT" <> value 12345)
in Config <$> location <*> port
main :: IO ()
main = do
Config {..} <- execParser $ info configP fullDesc
putStrLn $ "Location: " ++ location
putStrLn $ "Port: " ++ show port
run port . staticApp $ (defaultWebAppSettings location) {ssIndices = fromMaybe [] $ toPieces ["index.html"]}

19
server/default.nix Normal file
View File

@@ -0,0 +1,19 @@
{ pkgs, frontend }:
with pkgs;
let
server = haskell.lib.generateOptparseApplicativeCompletion "FlakeTest" (haskellPackages.callCabal2nix "FlakeTest" ./. {});
simple = runCommand "FlakeTest" {
src = server.src;
nativeBuildInputs = [ makeWrapper ];
} ''
makeWrapper ${server}/bin/FlakeTest $out/bin/FlakeTest \
--add-flags ${frontend} \
--add-flags 12345
'';
in
{
inherit server simple;
}

28
server/package.yaml Normal file
View File

@@ -0,0 +1,28 @@
_name: &name FlakeTest
name: *name
version: 1.0.0
ghc-options:
- -Wall
- -threaded
- -O2
dependencies:
- base
- filepath
- optparse-applicative
- wai
- wai-app-static
- warp
library:
source-dirs: src/
executables:
*name:
main: Main.hs
source-dirs: app/
dependencies:
- *name