Unverified Commit 54d71f7a authored by Lin Jian's avatar Lin Jian
Browse files

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.
parent 1476e32c
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -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))