NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.47k stars 13.66k forks source link

nginxModules.lua is broken. #227759

Open YellowOnion opened 1 year ago

YellowOnion commented 1 year ago

Describe the bug

I have this in my configuration.nix:

  services.nginx = {
    enable = true;
    additionalModules = [ pkgs.nginxModules.lua ];
};

gives me this error when trying to use the module:

Apr 23 21:09:00 Selene nginx[1314676]:         no file './lib/lua/5.1/loadall.so') in /nix/store/w5b5p6pqjsp3iqvmbnrg1s9v8pjdyx33-nginx.conf>
Apr 23 21:09:00 Selene nginx[1314676]:         no file './resty.so'
Apr 23 21:09:00 Selene nginx[1314676]:         no file './lib/lua/5.1/resty.so'
Apr 23 21:09:00 Selene nginx[1314676]:         no file './lib/lua/5.1/loadall.so'
Apr 23 21:09:00 Selene nginx[1314676]:         no file './resty/core.so'
Apr 23 21:09:00 Selene nginx[1314676]:         no file './lib/lua/5.1/resty/core.so'
Apr 23 21:09:00 Selene nginx[1314676]:         no file './resty/core/init.lua'
Apr 23 21:09:00 Selene nginx[1314676]:         no file './resty/core.lua'
Apr 23 21:09:00 Selene nginx[1314676]:         no file './share/lua/5.1/resty/core.lua'
Apr 23 21:09:00 Selene nginx[1314676]:         no field package.preload['resty.core']
Apr 23 21:09:00 Selene nginx[1314676]: nginx: [alert] failed to load the 'resty.core' module (https://github.com/openresty/lua-resty-core); >
Apr 23 21:09:00 Selene nginx[1314676]: nginx: [alert] detected a LuaJIT version which is not OpenResty's; many optimizations will be disable>
Apr 23 21:09:00 Selene systemd[1]: Started Nginx Web Server.

Additional context

https://github.com/openresty/lua-nginx-module/issues/1633

This mentions a lua_package_path directive requirement, but I can't seem to find what variable to use for this.

Notify maintainers

@thoughtpolice @raskin @fpletz @globin @ajs124

Metadata

 - system: `"x86_64-linux"`
 - host os: `Linux 6.1.7, NixOS, 23.05 (Stoat), 23.05pre447289.9b97ad7b433`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.12.0`
 - channels(root): `"nixos"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`
YellowOnion commented 1 year ago

I think we need to pull: https://github.com/openresty/lua-resty-core & https://github.com/openresty/lua-resty-lrucache as per the prereqs.

{
 httpConfig = let
      lua-resty-core =  pkgs.fetchFromGitHub {
        owner = "openresty";
        repo = "lua-resty-core";
        rev = "c48e90a8fc9d974d8a6a369e031940cedf473789";
        sha256 = "obwyxHSot1Lb2c1dNqJor3inPou+UIBrqldbkNBCQQk=";
      };
      in
      ''
      lua_package_path "${lua-resty-core}/lib/?.lua;;";
      init_by_lua_block {
        require "resty.core"
        collectgarbage("collect")
      }
      include /etc/nginx-rtmp/http.conf;
      '';
}

I have this and it's complaining about lrucache missing, so I guess that's on the right track.

wucke13 commented 1 year ago

Had an error in this, httpConfig should have been commonHttpConfig

{
commonHttpConfig =                                                                         
  let                                                                                
    lua-resty-core = pkgs.fetchFromGitHub {                                          
      owner = "openresty";                                                           
      repo = "lua-resty-core";                                                       
      rev = "v0.1.24";                                                               
      sha256 = "sha256-obwyxHSot1Lb2c1dNqJor3inPou+UIBrqldbkNBCQQk=";                
    };                                                                               
    lua-resty-lrucache = pkgs.fetchFromGitHub {                                      
      owner = "openresty";                                                           
      repo = "lua-resty-lrucache";                                                   
      rev = "v0.13";                                                                 
      sha256 = "sha256-4bb5o8QWNm6EtX8xC7euv8scZrZdOdKOpBdu4sWegU4=";                
    };                                                                               
  in                                                                                 
  ''
    lua_package_path "${lua-resty-core}/lib/?.lua;${lua-resty-lrucache}/lib/?.lua;;";                                                           
  '';
}                                                                       

worked for me