at master 1.6 kB view raw
1{ pkgs, lib, ... }: 2{ 3 name = "mod_perl"; 4 5 meta = with pkgs.lib.maintainers; { 6 maintainers = [ sgo ]; 7 }; 8 9 nodes.machine = 10 { 11 config, 12 lib, 13 pkgs, 14 ... 15 }: 16 { 17 services.httpd = { 18 enable = true; 19 adminAddr = "admin@localhost"; 20 virtualHosts."modperl" = 21 let 22 inc = pkgs.writeTextDir "ModPerlTest.pm" '' 23 package ModPerlTest; 24 use strict; 25 use Apache2::RequestRec (); 26 use Apache2::RequestIO (); 27 use Apache2::Const -compile => qw(OK); 28 sub handler { 29 my $r = shift; 30 $r->content_type('text/plain'); 31 print "Hello mod_perl!\n"; 32 return Apache2::Const::OK; 33 } 34 1; 35 ''; 36 startup = pkgs.writeScript "startup.pl" '' 37 use lib "${inc}", 38 split ":","${with pkgs.perl.pkgs; makeFullPerlPath ([ mod_perl2 ])}"; 39 1; 40 ''; 41 in 42 { 43 extraConfig = '' 44 PerlRequire ${startup} 45 ''; 46 locations."/modperl" = { 47 extraConfig = '' 48 SetHandler perl-script 49 PerlResponseHandler ModPerlTest 50 ''; 51 }; 52 }; 53 enablePerl = true; 54 }; 55 }; 56 testScript = 57 { ... }: 58 '' 59 machine.wait_for_unit("httpd.service") 60 response = machine.succeed("curl -fvvv -s http://127.0.0.1:80/modperl") 61 assert "Hello mod_perl!" in response, "/modperl handler did not respond" 62 ''; 63}