emacs: handle three arguments correctly for genericBuild

Without this patch, if there are nativeBuildInputs,
propagatedUserEnvPkgs or postInstall in the arguments of genericBuild,
they will override the value set by genericBuild.  With this patch
applied, the argument and the value set by genericBuild are merged
instead.
This commit is contained in:
Lin Jian 2024-07-19 22:33:12 +08:00
parent 1476e32c1d
commit 54d71f7a9c
No known key found for this signature in database
GPG Key ID: A6698D36434F75A5

View File

@ -4,7 +4,8 @@
let
inherit (lib) optionalAttrs getLib;
handledArgs = [ "buildInputs" "packageRequires" "meta" ];
handledArgs = [ "buildInputs" "packageRequires" "propagatedUserEnvPkgs" "meta" ]
++ lib.optionals (emacs.withNativeCompilation or false) [ "nativeBuildInputs" "postInstall" ];
setupHook = writeText "setup-hook.sh" ''
source ${./emacs-funcs.sh}
@ -25,7 +26,10 @@ in
{ pname
, version
, buildInputs ? []
, nativeBuildInputs ? []
, packageRequires ? []
, propagatedUserEnvPkgs ? []
, postInstall ? ""
, meta ? {}
, ...
}@args:
@ -51,7 +55,7 @@ stdenv.mkDerivation (finalAttrs: ({
buildInputs = [emacs texinfo] ++ packageRequires ++ buildInputs;
propagatedBuildInputs = packageRequires;
propagatedUserEnvPkgs = packageRequires;
propagatedUserEnvPkgs = packageRequires ++ propagatedUserEnvPkgs;
inherit setupHook;
@ -69,7 +73,7 @@ stdenv.mkDerivation (finalAttrs: ({
LIBRARY_PATH = "${getLib stdenv.cc.libc}/lib";
nativeBuildInputs = [ gcc ];
nativeBuildInputs = [ gcc ] ++ nativeBuildInputs;
addEmacsNativeLoadPath = true;
@ -84,7 +88,7 @@ stdenv.mkDerivation (finalAttrs: ({
find $out/share/emacs -type f -name '*.el' -print0 \
| xargs -0 -I {} -n 1 -P $NIX_BUILD_CORES sh -c \
"emacs --batch --eval '(setq large-file-warning-threshold nil)' -f batch-native-compile {} || true"
'';
'' + postInstall;
}
// removeAttrs args handledArgs))