Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 76 lines 1.9 kB view raw
1{ 2 callPackage, 3 runCommand, 4 lib, 5 fetchurl, 6 perl, 7 libpq, 8 nixosTests, 9 withPostgres ? true, 10 ... 11}@args: 12 13callPackage ../nginx/generic.nix args rec { 14 pname = "openresty"; 15 nginxVersion = "1.27.1"; 16 version = "${nginxVersion}.2"; 17 18 src = fetchurl { 19 url = "https://openresty.org/download/openresty-${version}.tar.gz"; 20 sha256 = "sha256-dPB29+NksqmabF+btTHCdhDHiYWr6Va0QrGSoilfdUg="; 21 }; 22 23 # generic.nix applies fixPatch on top of every patch defined there. 24 # This allows updating the patch destination, as openresty has 25 # nginx source code in a different folder. 26 fixPatch = 27 patch: 28 let 29 name = patch.name or (builtins.baseNameOf patch); 30 in 31 runCommand "openresty-${name}" { src = patch; } '' 32 substitute $src $out \ 33 --replace "a/" "a/bundle/nginx-${nginxVersion}/" \ 34 --replace "b/" "b/bundle/nginx-${nginxVersion}/" 35 ''; 36 37 nativeBuildInputs = [ 38 libpq.pg_config 39 perl 40 ]; 41 42 buildInputs = [ libpq ]; 43 44 postPatch = '' 45 substituteInPlace bundle/nginx-${nginxVersion}/src/http/ngx_http_core_module.c \ 46 --replace-fail '@nixStoreDir@' "$NIX_STORE" \ 47 --replace-fail '@nixStoreDirLen@' "''${#NIX_STORE}" 48 49 patchShebangs configure bundle/ 50 ''; 51 52 configureFlags = lib.optional withPostgres [ "--with-http_postgres_module" ]; 53 54 postInstall = '' 55 ln -s $out/luajit/bin/luajit-2.1.ROLLING $out/bin/luajit-openresty 56 ln -sf $out/nginx/bin/nginx $out/bin/openresty 57 ln -s $out/nginx/bin/nginx $out/bin/nginx 58 ln -s $out/nginx/conf $out/conf 59 ln -s $out/nginx/html $out/html 60 ''; 61 62 passthru.tests = { 63 inherit (nixosTests) openresty-lua; 64 }; 65 66 meta = { 67 description = "Fast web application server built on Nginx"; 68 homepage = "https://openresty.org"; 69 license = lib.licenses.bsd2; 70 platforms = lib.platforms.all; 71 maintainers = with lib.maintainers; [ 72 thoughtpolice 73 lblasc 74 ]; 75 }; 76}