at 23.05-pre 1.4 kB view raw
1import ./make-test-python.nix ({ pkgs, lib, ... }: 2 let 3 lualibs = [ 4 pkgs.lua.pkgs.markdown 5 ]; 6 7 getPath = lib: type: "${lib}/share/lua/${pkgs.lua.luaversion}/?.${type}"; 8 getLuaPath = lib: getPath lib "lua"; 9 luaPath = lib.concatStringsSep ";" (map getLuaPath lualibs); 10 in 11 { 12 name = "openresty-lua"; 13 meta = with pkgs.lib.maintainers; { 14 maintainers = [ bbigras ]; 15 }; 16 17 nodes = { 18 webserver = { pkgs, lib, ... }: { 19 services.nginx = { 20 enable = true; 21 package = pkgs.openresty; 22 23 commonHttpConfig = '' 24 lua_package_path '${luaPath};;'; 25 ''; 26 27 virtualHosts."default" = { 28 default = true; 29 locations."/" = { 30 extraConfig = '' 31 default_type text/html; 32 access_by_lua ' 33 local markdown = require "markdown" 34 markdown("source") 35 '; 36 ''; 37 }; 38 }; 39 }; 40 }; 41 }; 42 43 testScript = { nodes, ... }: 44 '' 45 url = "http://localhost" 46 47 webserver.wait_for_unit("nginx") 48 webserver.wait_for_open_port(80) 49 50 http_code = webserver.succeed( 51 f"curl -w '%{{http_code}}' --head --fail {url}" 52 ) 53 assert http_code.split("\n")[-1] == "200" 54 ''; 55 })