emacs: allow using as shebang on darwin

This commit is contained in:
Hraban Luyat 2023-09-04 01:20:27 -04:00 committed by Anderson Torres
parent 949ea0426d
commit 1b26fc011a
2 changed files with 9 additions and 4 deletions

View file

@ -32,7 +32,7 @@ in customEmacsPackages.withPackages (epkgs: [ epkgs.evil epkgs.magit ])
*/
{ lib, lndir, runCommand, gcc }:
{ lib, lndir, makeBinaryWrapper, runCommand, gcc }:
self:
let
inherit (self) emacs;
@ -50,7 +50,7 @@ runCommand
(lib.appendToName "with-packages" emacs).name
{
inherit emacs explicitRequires;
nativeBuildInputs = [ emacs lndir ];
nativeBuildInputs = [ emacs lndir makeBinaryWrapper ];
preferLocalBuild = true;
allowSubstitutes = false;
@ -201,6 +201,11 @@ runCommand
--subst-var-by wrapperSiteLispNative "$deps/share/emacs/native-lisp" \
--subst-var prog
chmod +x $out/bin/$progname
# Create a “NOP” binary wrapper for the pure sake of it becoming a
# non-shebang, actual binary. See the makeBinaryWrapper docs for rationale
# (summary: it allows you to use emacs as a shebang itself on Darwin,
# e.g. #!$ {emacs}/bin/emacs --script)
wrapProgramBinary $out/bin/$progname
done
# Wrap MacOS app
@ -220,6 +225,7 @@ runCommand
--subst-var-by wrapperSiteLispNative "$deps/share/emacs/native-lisp" \
--subst-var-by prog "$emacs/Applications/Emacs.app/Contents/MacOS/Emacs"
chmod +x $out/Applications/Emacs.app/Contents/MacOS/Emacs
wrapProgramBinary $out/Applications/Emacs.app/Contents/MacOS/Emacs
fi
mkdir -p $out/share

View file

@ -47,8 +47,7 @@ let
inherit lib pkgs;
};
emacsWithPackages = { pkgs, lib }: import ../build-support/emacs/wrapper.nix {
inherit (pkgs) makeWrapper runCommand gcc;
emacsWithPackages = { pkgs, lib }: pkgs.callPackage ../build-support/emacs/wrapper.nix {
inherit (pkgs.xorg) lndir;
inherit lib;
};