nix-community / emacs-overlay

Bleeding edge emacs overlay [maintainer=@adisbladis]
508 stars 168 forks source link

Org mode fails to build on `nixos-unstable` with Emacs overlay #411

Closed dschrempf closed 4 months ago

dschrempf commented 5 months ago

I think the reason is a security patch:

https://github.com/NixOS/nixpkgs/pull/321871

In particular, the patch file https://git.savannah.gnu.org/cgit/emacs/org-mode.git/patch/?id=f4cc61636947b5c2f0afc67174dd369fe3277aa8 fails to apply (I think because it is already applied):

@nix { "action": "setPhase", "phase": "unpackPhase" }
Running phase: unpackPhase
unpacking source archive /nix/store/c4iaxkhisi8zry6iq94pf1lw7fri5h1g-org-9.7.5.tar
source root is org-9.7.5
setting SOURCE_DATE_EPOCH to timestamp 1719090513 of file org-9.7.5/README-elpa
@nix { "action": "setPhase", "phase": "patchPhase" }
Running phase: patchPhase
applying patch /nix/store/14mqpyqvci1kzzm6rbs25dpx5avb61rg-?id=f4cc61636947b5c2f0afc67174dd369fe3277aa8
patching file ol.el
Reversed (or previously applied) patch detected!  Assume -R? [n]
Apply anyway? [n]
Skipping patch.
1 out of 1 hunk ignored -- saving rejects to file ol.el.rej
wfranzini commented 5 months ago

It fails also with 24.05 with the same error.

ParetoOptimalDev commented 5 months ago

The patch is now outdated maybe and needs removed? So two options I think:

This can be done with an overlay pretty easily probably, but I don't have time to write it and can't do it purely from memory.

ParetoOptimalDev commented 5 months ago

The patch is now outdated maybe and needs removed? So two options I think:

* skip patches that don't exist

* remove the patch if it's redundant

This can be done with an overlay pretty easily probably, but I don't have time to write it and can't do it purely from memory.

This built, no idea if it works or if there were other important patches it removes:

org = prev.org.overrideAttrs(old: { patches = []; } );

Edit: for newer users who might need more context on how to use this:

let myEmacs = pkgs.emacsWithPackagesFromUsePackage {
      override = final: prev: {
        org = prev.org.overrideAttrs(old: { patches = []; } );
      };
    }; in
{
  programs.emacs = {
    enable = true;
    package = myEmacs;
  };
}
ParetoOptimalDev commented 5 months ago

This built, no idea if it works or if there were other important patches it removes:

There were no other patches:

nix-repl> pkgs = import  (fetchTarball "https://github.com/nixos/nixpkgs/archive/2893f56de08021cffd9b6b6dfc70fd9ccd51eb60.tar.gz") {}
pkgs = import  (fetchTarball "https://github.com/nixos/nixpkgs/archive/2893f56de08021cffd9b6b6dfc70fd9ccd51eb60.tar.gz") {}

nix-repl> pkgs.emacsPackages.org.patches
pkgs.emacsPackages.org.patches
[ «derivation /nix/store/x73x2b0vrad58ksc9s24g4avg83srvki-?id=f4cc61636947b5c2f0afc67174dd369fe3277aa8.drv» ]
nagy commented 5 months ago

There were no other patches:

Thanks, I was also just looking that up. Your workaround probably works fine, but it should still be used only for a short while. To get notified ( via a build breakage ) if there are other patches to org-mode, that this workaround might remove, you could try something like this:

  org = prev.org.overrideAttrs (old: {
    patches =
      if ((builtins.length old.patches) == 1) then
        # Because of https://github.com/nix-community/emacs-overlay/issues/411
        [ ]
      else
        (throw "Remove this Emacs org-mode workaround");
  });
PlumpMath commented 5 months ago

I'd like to request a feature for emacs-overlay: not specifically related to this issue, but could you add a function like ignore-build-pass? that allows us to bypass and build without considering the last successful build in nixos nixpkgs. It would be similar to an override.

jian-lin commented 5 months ago

should be fixed by https://github.com/NixOS/nixpkgs/pull/322721