diff options
author | Profpatsch <mail@profpatsch.de> | 2017-01-19 14:34:12 +0100 |
---|---|---|
committer | Profpatsch <mail@profpatsch.de> | 2017-01-19 14:35:36 +0100 |
commit | 1981ee3ee7078a6bc7bb613d871885295c23b603 (patch) | |
tree | 71322e35d30a2b5bfe883234c20b8738fce799bc /pkgs/profpatsch | |
parent | d75546b563db5742123114bf43ccaff38898d8bd (diff) |
warpspeed: init
Diffstat (limited to 'pkgs/profpatsch')
-rw-r--r-- | pkgs/profpatsch/warpspeed/default.nix | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/pkgs/profpatsch/warpspeed/default.nix b/pkgs/profpatsch/warpspeed/default.nix new file mode 100644 index 00000000..a73169b5 --- /dev/null +++ b/pkgs/profpatsch/warpspeed/default.nix @@ -0,0 +1,34 @@ +{ lib, runCommand, ghcWithPackages }: + +let + name = "warpspeed-1.0"; + + script = builtins.toFile "${name}.hs" '' + {-# LANGUAGE OverloadedStrings #-} + module Main where + + import Safe + import System.Environment (getArgs) + import System.Exit (die) + import Network.Wai + import Network.Wai.Middleware.Static + import Network.Wai.Handler.Warp + import Network.HTTP.Types.Status + + main :: IO () + main = do + args <- getArgs + port <- case headMay args >>= readMay of + Just p -> pure $ p + Nothing -> die "please specify a port" + runEnv port $ static $ \_ resp -> resp $ responseLBS notFound404 [] "" + ''; + + deps = hp: with hp; [ wai-middleware-static warp safe ]; + +in runCommand name { + meta.description = "Trivial and very fast static HTTP file server"; +} '' + mkdir -p $out/bin + ${ghcWithPackages deps}/bin/ghc -O2 -Wall -o "$out/bin/warpspeed" ${script} +'' |