Unverified Commit 56838849 authored by adisbladis's avatar adisbladis Committed by GitHub
Browse files

Merge pull request #334663 from linj-fork/pr/notdeft-override

emacsPackages.notdeft: make the native binary overridable
parents 30de35ad 385a5146
Loading
Loading
Loading
Loading
+20 −39
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@
  withIvy ? false,
}:

let
melpaBuild {
  pname = "notdeft";
  version = "0-unstable-2021-12-04";

@@ -27,10 +27,20 @@ let
    hash = "sha256-LMMLJFVpmoE/y3MqrgY2fmsehmzk6TkLsVoHmFUxiSw=";
  };

  # Xapian bindings for NotDeft
  notdeft-xapian = stdenv.mkDerivation {
    pname = "notdeft-xapian";
    inherit version src;
  packageRequires = lib.optional withHydra hydra ++ lib.optional withIvy ivy;

  postPatch = ''
    substituteInPlace notdeft-xapian.el \
      --replace-fail 'defcustom notdeft-xapian-program nil' \
                     "defcustom notdeft-xapian-program \"$out/bin/notdeft-xapian\""
  '';

  files = ''
    (:defaults
     ${lib.optionalString withHydra ''"extras/notdeft-global-hydra.el"''}
     ${lib.optionalString withHydra ''"extras/notdeft-mode-hydra.el"''}
     ${lib.optionalString withIvy ''"extras/notdeft-ivy.el"''})
  '';

  strictDeps = true;

@@ -41,44 +51,15 @@ let
    xapian
  ];

    buildPhase = ''
      runHook preBuild

  preBuild = ''
    $CXX -std=c++11 -o notdeft-xapian xapian/notdeft-xapian.cc -lxapian

      runHook postBuild
    '';

    installPhase = ''
      runHook preInstall

      mkdir -p $out/bin
      cp notdeft-xapian $out/bin

      runHook postInstall
    '';
  };
in
melpaBuild {
  inherit pname version src;

  packageRequires = lib.optional withHydra hydra ++ lib.optional withIvy ivy;

  postPatch = ''
    substituteInPlace notdeft-xapian.el \
      --replace 'defcustom notdeft-xapian-program nil' \
                "defcustom notdeft-xapian-program \"${notdeft-xapian}/bin/notdeft-xapian\""
  '';

  files = ''
    (:defaults
     ${lib.optionalString withHydra ''"extras/notdeft-global-hydra.el"''}
     ${lib.optionalString withHydra ''"extras/notdeft-mode-hydra.el"''}
     ${lib.optionalString withIvy ''"extras/notdeft-ivy.el"''})
  preInstall = ''
    install -D --target-directory=$out/bin source/notdeft-xapian
  '';

  passthru = {
    inherit notdeft-xapian;
    updateScript = unstableGitUpdater { hardcodeZeroVersion = true; };
  };