From 6e5f9e8b49fea75838cc29a1d9a944ab211b79a3 Mon Sep 17 00:00:00 2001 From: Lin Jian Date: Thu, 20 Mar 2025 04:40:23 +0800 Subject: [PATCH 1/4] emacs: bump package-build used by melpaBuild This bump causes a few build failures because package--description-file cannot correctly parse some package names. We report that to upstream Emacs as bug#77143. Refer to that bug for more information. A dirty patch is vendored in elpa2nix.el to fix those build failures. This bump also fixes magit-p4 build failure[1]. [1]: https://hydra.nix-community.org/build/4516070 --- .../editors/emacs/build-support/elpa2nix.el | 10 +++++++++ .../editors/emacs/build-support/melpa.nix | 9 +++++--- .../editors/emacs/build-support/melpa2nix.el | 8 +++---- .../package-build-dont-use-mtime.patch | 21 ------------------- 4 files changed, 19 insertions(+), 29 deletions(-) delete mode 100644 pkgs/applications/editors/emacs/build-support/package-build-dont-use-mtime.patch diff --git a/pkgs/applications/editors/emacs/build-support/elpa2nix.el b/pkgs/applications/editors/emacs/build-support/elpa2nix.el index 5b363b7b6640..40d822fdb6dc 100644 --- a/pkgs/applications/editors/emacs/build-support/elpa2nix.el +++ b/pkgs/applications/editors/emacs/build-support/elpa2nix.el @@ -1,6 +1,16 @@ (require 'package) (package-initialize) +;; TODO remove this patch when Emacs bug#77143 is fixed +;; see that bug for more info +(defun package--description-file (dir) + "Return package description file name for package DIR." + (concat (let ((subdir (file-name-nondirectory + (directory-file-name dir)))) + (if (string-match "\\([^.].*?\\)-\\([0-9]+\\(?:[.][0-9]+\\|\\(?:pre\\|beta\\|alpha\\|snapshot\\)[0-9]+\\)*\\)\\'" subdir) + (match-string 1 subdir) subdir)) + "-pkg.el")) + (defun elpa2nix-install-package () (if (not noninteractive) (error "`elpa2nix-install-package' is to be used only with -batch")) diff --git a/pkgs/applications/editors/emacs/build-support/melpa.nix b/pkgs/applications/editors/emacs/build-support/melpa.nix index 876cf9a46ddc..0c77acc9d6b4 100644 --- a/pkgs/applications/editors/emacs/build-support/melpa.nix +++ b/pkgs/applications/editors/emacs/build-support/melpa.nix @@ -24,11 +24,14 @@ let src = fetchFromGitHub { owner = "melpa"; repo = "package-build"; - rev = "d5661f1f1996a893fbcbacb4d290c57acab4fb0e"; - hash = "sha256-zVhFR2kLLkCKC+esPBbIk3qOa033YND1HF9GiNI4JM8="; + rev = "d1722503145facf96631ac118ec0213a73082b76"; + hash = "sha256-utsZLm9IF9UkTwxFWvJmwA3Ox4tlMeNNTo+f/CqYJGA="; }; - patches = [ ./package-build-dont-use-mtime.patch ]; + prePatch = '' + substituteInPlace package-build.el \ + --replace-fail '(format "--mtime=@%d" time)' '"--mtime=@0"' + ''; dontConfigure = true; dontBuild = true; diff --git a/pkgs/applications/editors/emacs/build-support/melpa2nix.el b/pkgs/applications/editors/emacs/build-support/melpa2nix.el index 91706e92f733..f2cb334f4c41 100644 --- a/pkgs/applications/editors/emacs/build-support/melpa2nix.el +++ b/pkgs/applications/editors/emacs/build-support/melpa2nix.el @@ -12,11 +12,9 @@ (let* ((default-directory (package-recipe--working-tree rcp))) (unwind-protect (let ((files (package-build-expand-files-spec rcp t))) - (unless files - (error "Unable to find files matching recipe patterns")) - (if (> (length files) 1) - (package-build--build-multi-file-package rcp files) - (package-build--build-single-file-package rcp files)))))) + (if files + (funcall package-build-build-function rcp files) + (error "Unable to find files matching recipe patterns")))))) (defun melpa2nix-build-package () (unless noninteractive diff --git a/pkgs/applications/editors/emacs/build-support/package-build-dont-use-mtime.patch b/pkgs/applications/editors/emacs/build-support/package-build-dont-use-mtime.patch deleted file mode 100644 index 1ace7771ea3a..000000000000 --- a/pkgs/applications/editors/emacs/build-support/package-build-dont-use-mtime.patch +++ /dev/null @@ -1,21 +0,0 @@ -diff --git a/package-build.el b/package-build.el -index 29cdb61..c19be1b 100644 ---- a/package-build.el -+++ b/package-build.el -@@ -923,7 +923,6 @@ DIRECTORY is a temporary directory that contains the directory - that is put in the tarball." - (let* ((name (oref rcp name)) - (version (oref rcp version)) -- (time (oref rcp time)) - (tar (expand-file-name (concat name "-" version ".tar") - package-build-archive-dir)) - (dir (concat name "-" version))) -@@ -939,7 +938,7 @@ that is put in the tarball." - ;; prevent a reproducible tarball as described at - ;; https://reproducible-builds.org/docs/archives. - "--sort=name" -- (format "--mtime=@%d" time) -+ "--mtime=@0" - "--owner=0" "--group=0" "--numeric-owner" - "--pax-option=exthdr.name=%d/PaxHeaders/%f,delete=atime,delete=ctime")) - (when (and package-build-verbose noninteractive) From 23984b23151c4ed9035f2856180e5c465184f376 Mon Sep 17 00:00:00 2001 From: Lin Jian Date: Thu, 20 Mar 2025 06:36:55 +0800 Subject: [PATCH 2/4] emacs.pkgs.color-theme-solarized: fix build --- .../manual-packages/color-theme-solarized/package.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkgs/applications/editors/emacs/elisp-packages/manual-packages/color-theme-solarized/package.nix b/pkgs/applications/editors/emacs/elisp-packages/manual-packages/color-theme-solarized/package.nix index e544c4cca18b..0d3903fb81f9 100644 --- a/pkgs/applications/editors/emacs/elisp-packages/manual-packages/color-theme-solarized/package.nix +++ b/pkgs/applications/editors/emacs/elisp-packages/manual-packages/color-theme-solarized/package.nix @@ -6,6 +6,7 @@ melpaBuild { pname = "color-theme-solarized"; + ename = "solarized-theme"; version = "0-unstable-2023-02-09"; src = fetchFromGitHub { @@ -15,6 +16,8 @@ melpaBuild { hash = "sha256-7E8r56dzfD06tsQEnqU5mWSbwz9x9QPbzken2J/fhlg="; }; + files = ''(:defaults (:exclude "color-theme-solarized-pkg.el"))''; + # https://github.com/NixOS/nixpkgs/issues/335408 ignoreCompilationError = true; From bcdc68e3410d7ae6cdce8e05cf7775fc2bc5e94a Mon Sep 17 00:00:00 2001 From: Lin Jian Date: Sat, 29 Mar 2025 13:58:07 +0800 Subject: [PATCH 3/4] emacs.pkgs.session-management-for-emacs: fix build --- .../manual-packages/session-management-for-emacs/package.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/applications/editors/emacs/elisp-packages/manual-packages/session-management-for-emacs/package.nix b/pkgs/applications/editors/emacs/elisp-packages/manual-packages/session-management-for-emacs/package.nix index 495e274735f4..9896e8bd4b35 100644 --- a/pkgs/applications/editors/emacs/elisp-packages/manual-packages/session-management-for-emacs/package.nix +++ b/pkgs/applications/editors/emacs/elisp-packages/manual-packages/session-management-for-emacs/package.nix @@ -8,6 +8,7 @@ melpaBuild rec { pname = "session-management-for-emacs"; ename = "session"; version = "2.2a"; + melpaVersion = "2.2"; # default value derived from version is not valid for Emacs src = fetchzip { url = "mirror://sourceforge/emacs-session/session-${version}.tar.gz"; From 4a760ed59d235769c666a56f072e9a27d41f4c43 Mon Sep 17 00:00:00 2001 From: Lin Jian Date: Sat, 29 Mar 2025 15:51:27 +0800 Subject: [PATCH 4/4] emacs.pkgs.pod-mode: fix build --- .../emacs/elisp-packages/manual-packages/pod-mode/package.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/applications/editors/emacs/elisp-packages/manual-packages/pod-mode/package.nix b/pkgs/applications/editors/emacs/elisp-packages/manual-packages/pod-mode/package.nix index bf6d2aef72ce..88bf60e1cc16 100644 --- a/pkgs/applications/editors/emacs/elisp-packages/manual-packages/pod-mode/package.nix +++ b/pkgs/applications/editors/emacs/elisp-packages/manual-packages/pod-mode/package.nix @@ -15,6 +15,7 @@ let in melpaBuild { inherit pname version src; + melpaVersion = "1.4"; # upstream versions such as 1.04 are not supported outputs = [ "out"