summary refs log tree commit diff
path: root/nixos/modules/services/web-servers/apache-httpd/default.nix
diff options
context:
space:
mode:
authorDaniel Nagy <danielnagy@posteo.de>2021-01-05 21:04:57 +0100
committerDaniel Nagy <danielnagy@posteo.de>2021-02-11 11:56:06 +0100
commit7c121e60c5625eb7683fbbc12cb1d6ac9bdc1744 (patch)
treebb2f10c4d4aaac1a7f190f63cf790c20829dc6cb /nixos/modules/services/web-servers/apache-httpd/default.nix
parentdd65c8b2a7c936f2456c4d2c7a2dc6789bc3f177 (diff)
downloadnixpkgs-7c121e60c5625eb7683fbbc12cb1d6ac9bdc1744.tar
nixpkgs-7c121e60c5625eb7683fbbc12cb1d6ac9bdc1744.tar.gz
nixpkgs-7c121e60c5625eb7683fbbc12cb1d6ac9bdc1744.tar.bz2
nixpkgs-7c121e60c5625eb7683fbbc12cb1d6ac9bdc1744.tar.lz
nixpkgs-7c121e60c5625eb7683fbbc12cb1d6ac9bdc1744.tar.xz
nixpkgs-7c121e60c5625eb7683fbbc12cb1d6ac9bdc1744.tar.zst
nixpkgs-7c121e60c5625eb7683fbbc12cb1d6ac9bdc1744.zip
nixos/httpd: fix lua paths
Account for the fact that, when creating a lua package without the
"withPackages" helper, we dont get an extra "lua" attribute in the
package.

Therefore we need to distinguish between the "withPackages" case and the
direct ( or "empty" ) lua package.

For example with this nixos config:

```nix
{
  services.httpd = {
      enable = true;
      package = pkgs.apacheHttpd.override {
        luaSupport = true;
        lua5 = pkgs.lua5_3.withPackages (ps: with ps; [ luafilesystem ] );
      };
    };
}
```

Here we say that we want to have apache to use a lua, packaged with the
`luafilesystem` module so that we can `require` that in scripts to
render http responses. There, the set that gets assigned to `lua5 ` does
not have a `luaversion` attribute, rather it has a `lua` attribute
wherein lies a `luaversion` attribute. If we dont package additional
modules, then we dont have that `lua` attribute in between and rather
directly have to use `luaversion` directly.
Diffstat (limited to 'nixos/modules/services/web-servers/apache-httpd/default.nix')
-rw-r--r--nixos/modules/services/web-servers/apache-httpd/default.nix12
1 files changed, 8 insertions, 4 deletions
diff --git a/nixos/modules/services/web-servers/apache-httpd/default.nix b/nixos/modules/services/web-servers/apache-httpd/default.nix
index de3c7d693d4..7f50b8fd8d4 100644
--- a/nixos/modules/services/web-servers/apache-httpd/default.nix
+++ b/nixos/modules/services/web-servers/apache-httpd/default.nix
@@ -126,10 +126,14 @@ let
     </IfModule>
   '';
 
-  luaSetPaths = ''
+  luaSetPaths = let
+    # support both lua and lua.withPackages derivations
+    luaversion = cfg.package.lua5.lua.luaversion or cfg.package.lua5.luaversion;
+    in
+  ''
     <IfModule mod_lua.c>
-      LuaPackageCPath ${cfg.package.lua5}/lib/lua/${cfg.package.lua5.lua.luaversion}/?.so
-      LuaPackagePath  ${cfg.package.lua5}/share/lua/${cfg.package.lua5.lua.luaversion}/?.lua
+      LuaPackageCPath ${cfg.package.lua5}/lib/lua/${luaversion}/?.so
+      LuaPackagePath  ${cfg.package.lua5}/share/lua/${luaversion}/?.lua
     </IfModule>
   '';
 
@@ -333,7 +337,7 @@ let
 
     ${sslConf}
 
-    ${if cfg.package.luaSupport then luaSetPaths else ""}
+    ${optionalString cfg.package.luaSupport luaSetPaths}
 
     # Fascist default - deny access to everything.
     <Directory />