From b3eca67865e2aecc2105f7277ee73daaa5e05756 Mon Sep 17 00:00:00 2001 From: Christoph Heiss Date: Fri, 6 Dec 2024 19:15:26 +0100 Subject: [PATCH] nixos/openresty: fix build with nginx modules (#362348) When adding modules to openresty, by either - using `.override { modules = [ ..]; }` directly - adding them to `services.nginx.additionalModules` or - enabling e.g. something like `services.nginx.recommendedZstdSettings` the build will then fail, as the actual `nginx` binary lands in `nginx/bin/nginx` for openresty, and is only symlinked to `bin/nginx` (and `bin/openresty`, for that matter). This breaks the post-install script for nginx when removing references to the aforementioned modules, since `remove-references-to` skips symlinks. Thus, just read the symlink before in this case. `readlink -fn` will read the symlink if it is one, otherwise just returns the path itself. The phase is also moved after the package-specific postInstall phase, at that might move binaries around or create symlinks - as is the case for openresty. Can be easily reproduced using e.g.: $ nix build --impure -E 'with import ./. {}; openresty.override { modules = [ nginxModules.zstd ]; }' -L Signed-off-by: Christoph Heiss --- pkgs/servers/http/nginx/generic.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/servers/http/nginx/generic.nix b/pkgs/servers/http/nginx/generic.nix index 0d38e49d6276..23f42fa49df4 100644 --- a/pkgs/servers/http/nginx/generic.nix +++ b/pkgs/servers/http/nginx/generic.nix @@ -206,8 +206,8 @@ stdenv.mkDerivation { postInstall = let - noSourceRefs = lib.concatMapStrings (m: "remove-references-to -t ${m.src} $out/bin/nginx\n") modules; - in noSourceRefs + postInstall; + noSourceRefs = lib.concatMapStrings (m: "remove-references-to -t ${m.src} $(readlink -fn $out/bin/nginx)\n") modules; + in postInstall + noSourceRefs; passthru = { inherit modules;