initial commit
This commit is contained in:
30
server/app/Main.hs
Normal file
30
server/app/Main.hs
Normal 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
19
server/default.nix
Normal 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
28
server/package.yaml
Normal 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
|
||||
|
||||
Reference in New Issue
Block a user