From 86e4d00f309bc447c3add1ce65eb9a72a941ced7 Mon Sep 17 00:00:00 2001 From: Anthony Cowley Date: Tue, 31 Oct 2023 09:32:59 -0400 Subject: [PATCH] melpa-packages: build osx-dictionary helper executable The `osx-dictionary` emacs package tries to build a helper executable if it is not found at runtime. This fails with `nix` installations of the package, so we build it at build time. --- .../emacs/elisp-packages/melpa-packages.nix | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/pkgs/applications/editors/emacs/elisp-packages/melpa-packages.nix b/pkgs/applications/editors/emacs/elisp-packages/melpa-packages.nix index 2cf64953628d..c2754d7fc30f 100644 --- a/pkgs/applications/editors/emacs/elisp-packages/melpa-packages.nix +++ b/pkgs/applications/editors/emacs/elisp-packages/melpa-packages.nix @@ -688,6 +688,27 @@ let --replace '"mozc_emacs_helper"' '"${pkgs.ibus-engines.mozc}/lib/mozc/mozc_emacs_helper"' ''; }); + + # Build a helper executable that interacts with the macOS Dictionary.app + osx-dictionary = + if pkgs.stdenv.isDarwin + then super.osx-dictionary.overrideAttrs (old: { + buildInputs = + old.buildInputs ++ + (with pkgs.darwin.apple_sdk.frameworks; [CoreServices Foundation]); + dontUnpack = false; + buildPhase = (old.buildPhase or "") + '' + cd source + $CXX -O3 -framework CoreServices -framework Foundation osx-dictionary.m -o osx-dictionary-cli + ''; + postInstall = (old.postInstall or "") + "\n" + '' + outd=$out/share/emacs/site-lisp/elpa/osx-dictionary-* + mkdir -p $out/bin + install -m444 -t $out/bin osx-dictionary-cli + rm $outd/osx-dictionary.m + ''; + }) + else super.osx-dictionary; }; in lib.mapAttrs (n: v: if lib.hasAttr n overrides then overrides.${n} else v) super);