nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{ callPackage
2, runCommand
3, lib
4, fetchurl
5, perl
6, postgresql
7, nixosTests
8, ...
9}@args:
10
11callPackage ../nginx/generic.nix args rec {
12 pname = "openresty";
13 nginxVersion = "1.21.4";
14 version = "${nginxVersion}.1";
15
16 src = fetchurl {
17 url = "https://openresty.org/download/openresty-${version}.tar.gz";
18 sha256 = "sha256-DFCTtk94IehQZcmeXU5swxggz9fze5oN7IQgnYeir5k=";
19 };
20
21 # generic.nix applies fixPatch on top of every patch defined there.
22 # This allows updating the patch destination, as openresty has
23 # nginx source code in a different folder.
24 fixPatch = patch:
25 let name = patch.name or (builtins.baseNameOf patch); in
26 runCommand "openresty-${name}" { src = patch; } ''
27 substitute $src $out \
28 --replace "a/" "a/bundle/nginx-${nginxVersion}/" \
29 --replace "b/" "b/bundle/nginx-${nginxVersion}/"
30 '';
31
32 nativeBuildInputs = [ perl ];
33
34 buildInputs = [ postgresql ];
35
36 postPatch = ''
37 patchShebangs configure bundle/
38 '';
39
40 configureFlags = [ "--with-http_postgres_module" ];
41
42 postInstall = ''
43 ln -s $out/luajit/bin/luajit-2.1.0-beta3 $out/bin/luajit-openresty
44 ln -s $out/nginx/sbin/nginx $out/bin/nginx
45 ln -s $out/nginx/conf $out/conf
46 ln -s $out/nginx/html $out/html
47 '';
48
49 passthru.tests = {
50 inherit (nixosTests) openresty-lua;
51 };
52
53 meta = {
54 description = "A fast web application server built on Nginx";
55 homepage = "https://openresty.org";
56 license = lib.licenses.bsd2;
57 platforms = lib.platforms.all;
58 maintainers = with lib.maintainers; [ thoughtpolice lblasc emily ];
59 };
60}