From 93561e675dd60c5447db8a56f66f8c945a1a5537 Mon Sep 17 00:00:00 2001 From: Acid Bong Date: Thu, 3 Apr 2025 11:17:38 +0300 Subject: [PATCH] emacs/wrapper.nix: link included executables by their resolved paths This allows bundling Emacs with packages like `nodePackages.prettier`, whose executables are relative symlinks. Fixes #395442 --- .../editors/emacs/build-support/wrapper.nix | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/pkgs/applications/editors/emacs/build-support/wrapper.nix b/pkgs/applications/editors/emacs/build-support/wrapper.nix index 7bef6596b62a..8a36c507afff 100644 --- a/pkgs/applications/editors/emacs/build-support/wrapper.nix +++ b/pkgs/applications/editors/emacs/build-support/wrapper.nix @@ -125,9 +125,19 @@ runCommand (lib.appendToName "with-packages" emacs).name local origin_path=$2 local dest_path=$3 - # Add the path to the search path list, but only if it exists + # Add the path to the search path list, but only if it exists. + # Executables in /bin are linked by their resolved paths in case they are + # relative symlinks (which break when 'lndir'ed as is); + # see https://github.com/NixOS/nixpkgs/issues/395442 if [[ -d "$pkg/$origin_path" ]]; then - $lndir/bin/lndir -silent "$pkg/$origin_path" "$out/$dest_path" + case "$origin_path" in + bin) + for exe in $pkg/$origin_path/*; do + ln -s "$(realpath "$exe")" "$out/$dest_path/$(basename "$exe")" + done + ;; + *) $lndir/bin/lndir -silent "$pkg/$origin_path" "$out/$dest_path";; + esac fi }