Skip to content
This repository was archived by the owner on Feb 6, 2024. It is now read-only.

Commit b6bd0d5

Browse files
committed
wai-lambda: prepare for release
1 parent 427d98e commit b6bd0d5

File tree

13 files changed

+166
-6
lines changed

13 files changed

+166
-6
lines changed

infra/nix/default.nix

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,21 @@ with rec
1212
with
1313
{ mkPackage = name: path:
1414
{ "${name}" =
15-
pkgs'.haskell.lib.disableLibraryProfiling (
16-
pkgs'.haskell.lib.disableExecutableProfiling (
17-
pkgs'.haskell.lib.failOnAllWarnings (
15+
with pkgs'.haskell.lib;
16+
disableLibraryProfiling (
17+
disableExecutableProfiling (
18+
failOnAllWarnings (
1819
super.callCabal2nix name (pkgs'.lib.cleanSource path) {}
1920
)));
2021
};
2122
};
2223

2324
super //
2425
mkPackage "deckdeckgo-handler" ../handler //
25-
mkPackage "wai-lambda" ../wai-lambda ;
26-
26+
(
27+
with { wai-lambda = pkgs'.callPackage ../wai-lambda/nix/packages.nix {}; };
28+
mkPackage "wai-lambda" wai-lambda.wai-lambda-source
29+
);
2730
};
2831
normalHaskellPackages = pkgsStatic.pkgsMusl.haskellPackages.override
2932
(haskellOverride pkgsStatic.pkgsMusl);

infra/wai-lambda/LICENSE

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2017 Nicolas Mattia
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19+
SOFTWARE.
21.7 KB
Loading

infra/wai-lambda/default.nix

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
with { pkgs = import ./nix {}; };
2+
pkgs.callPackage ./nix/packages.nix {}

infra/wai-lambda/examples/Hello.hs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{-# LANGUAGE OverloadedStrings #-}
2+
import Network.Wai
3+
import Network.HTTP.Types
4+
import Network.Wai.Handler.Lambda (run)
5+
6+
app :: Application
7+
app _ respond = do
8+
putStrLn "I've done some IO here"
9+
respond $ responseLBS
10+
status200
11+
[("Content-Type", "text/plain")]
12+
"Hello, Web!"
13+
14+
main :: IO ()
15+
main = run app

infra/wai-lambda/nix/default.nix

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{ sources ? import ./sources.nix }:
2+
with
3+
{ overlay = _: pkgs:
4+
{ inherit (import sources.niv {}) niv;
5+
packages = import ./packages.nix { inherit (pkgs) haskell lib haskellPackages; };
6+
};
7+
};
8+
import sources.nixpkgs
9+
{ overlays = [ overlay ] ; config = {}; }

infra/wai-lambda/nix/packages.nix

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{ haskell
2+
, haskellPackages
3+
, lib
4+
, writeText
5+
}:
6+
rec
7+
{ wai-lambda-sdist = haskell.lib.sdistTarball wai-lambda;
8+
wai-lambda = haskellPackages.callCabal2nix "wai-lambda" wai-lambda-source {};
9+
wai-lambda-source = lib.sourceByRegex ../.
10+
[ "^package.yaml$"
11+
"^src.*"
12+
"^examples.*"
13+
"^README.md$"
14+
"^LICENSE$"
15+
];
16+
wai-lambda-version-file = writeText "version" wai-lambda.version;
17+
}

infra/wai-lambda/nix/sources.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"nixpkgs": {
3+
"url": "https://github.com/NixOS/nixpkgs/archive/88ae8f7d55efa457c95187011eb410d097108445.tar.gz",
4+
"owner": "NixOS",
5+
"branch": "nixos-18.09",
6+
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz",
7+
"repo": "nixpkgs",
8+
"sha256": "0qvpzmphdcc80xp88h0ciiia6w25010piwxvslv3b5q6s9m3f6fm",
9+
"description": "Nixpkgs/NixOS branches that track the Nixpkgs/NixOS channels",
10+
"rev": "88ae8f7d55efa457c95187011eb410d097108445"
11+
},
12+
"niv": {
13+
"homepage": "https://github.com/nmattia/niv",
14+
"url": "https://github.com/nmattia/niv/archive/7f72d723d00fcc3f177138acbfcf9d581beee9e1.tar.gz",
15+
"owner": "nmattia",
16+
"branch": "master",
17+
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz",
18+
"repo": "niv",
19+
"sha256": "0177xhz55519xrak1fmv3gilbg8330lmbfkbizkc8zgp58skcmjw",
20+
"description": "Easy dependency management for Nix projects",
21+
"rev": "7f72d723d00fcc3f177138acbfcf9d581beee9e1"
22+
}
23+
}

infra/wai-lambda/nix/sources.nix

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# A record, from name to path, of the third-party packages
2+
with
3+
{
4+
sources = builtins.fromJSON (builtins.readFile ./sources.json);
5+
6+
# fetchTarball version that is compatible between all the sources of Nix
7+
fetchTarball =
8+
{ url, sha256 }:
9+
if builtins.lessThan builtins.nixVersion "1.12" then
10+
builtins.fetchTarball { inherit url; }
11+
else
12+
builtins.fetchTarball { inherit url sha256; };
13+
mapAttrs = builtins.mapAttrs or
14+
(f: set: with builtins;
15+
listToAttrs (map (attr: { name = attr; value = f attr set.${attr}; }) (attrNames set)));
16+
};
17+
18+
# NOTE: spec must _not_ have an "outPath" attribute
19+
mapAttrs (_: spec:
20+
if builtins.hasAttr "outPath" spec
21+
then abort
22+
"The values in sources.json should not have an 'outPath' attribute"
23+
else
24+
if builtins.hasAttr "url" spec && builtins.hasAttr "sha256" spec
25+
then
26+
spec //
27+
{ outPath = fetchTarball { inherit (spec) url sha256; } ; }
28+
else spec
29+
) sources

infra/wai-lambda/package.yaml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,29 @@
11
name: wai-lambda
22
version: 0.1.0.0
3+
author: Nicolas Mattia <[email protected]>
34
maintainer: Nicolas Mattia <[email protected]>
45
copyright: (c) 2019 David Dal Busco and Nicolas Mattia
56
license: MIT
7+
license-file: LICENSE
8+
category: Web
9+
synopsis: Haskell Webapps on AWS Lambda
10+
github: deckgo/wai-lambda
11+
description: |
12+
13+
![wai-lambda](https://github.com/deckgo/wai-lambda/raw/master/assets/wai-lambda-small.png)
14+
15+
Turn any [wai](https://www.stackage.org/package/wai) webapp ( [spock](https://www.spock.li/), [servant](https://docs.servant.dev/en/stable/), etc) into a handler for AWS [Lambda](https://aws.amazon.com/lambda/) and [API Gateway](https://aws.amazon.com/api-gateway/) requests.
16+
17+
Works with any Lambda environment (nodejs, python, etc). Find out more in the [README](https://github.com/deckgo/wai-lambda#wai-lambda---haskell-webapps-on-aws-lambda).
18+
extra-source-files:
19+
- README.md
620

721
library:
822
source-dirs: ./src
923

1024
dependencies:
1125
- aeson
12-
- base
26+
- base < 5
1327
- binary
1428
- bytestring
1529
- case-insensitive
@@ -24,5 +38,11 @@ dependencies:
2438
- vault
2539
- wai
2640

41+
executable:
42+
name: wai-lambda-hello
43+
main: examples/Hello.hs
44+
dependencies:
45+
- wai-lambda
46+
2747
ghc-options:
2848
- -Wall

0 commit comments

Comments
 (0)