(name . guix-patches@gnu.org)(address . guix-patches@gnu.org)
Hello,
I have been using a local package for installing Spacemacs (https://github.com/syl20bnr/spacemacs)and would like to contribute it. I ran through the packaging guidelines and believe that everything should be in order - though note that the way I personally format lisp code is not standard, so while I tried to match the style I saw in the repository there may be some feedback there. There are 2 new packages added, spacemacs-rolling-release (to add the spacemacs code to the store) and emacs-spacemacs (to install the spacemacs command which launches vanilla emacs with command-line options to load emacs, which allows for side-by-side installations of vanilla emacs and spacemacs). There are 3 patch files which have been included to address bugs that arise when upstream spacemacs is installed to a read-only filesystem.
Both packages have 2 lint warnings which I believe are acceptable. Each has a lint error for the description line being too long, but the description follows the advice in the "Synopses and Descriptions" section of the manual, and I can't break it into multiple lines because it must be a string literal. The other warning is that the TLS certificate of spacemacs.org, the package's main website, does not match that of github.com, where the code is hosted.
Below is the output of `guix format-patch -1`. Let me know if any additional work is needed.
Thanks,
Bryan
From 67e44b3cdec7248d00ca2b10b5617738ab3f0d45 Mon Sep 17 00:00:00 2001
From: Bryan Ferris <saffronsnail@protonmail.com>
Date: Wed, 11 Dec 2019 23:57:26 -0800
Subject: [PATCH] gnu: Add emacs-spacemacs
* gnu/packages/patches/spacemacs-rolling-release-add-data-dir.patch: New file.
* gnu/packages/patches/spacemacs-rolling-release-inhibit-read-only.patch: New file.
* gnu/packages/patches/spacemacs-rolling-release-quelpa-permissions.patch: New file.
* gnu/packages/spacemacs.scm: New file.
* guix/build/spacemacs-utils.scm: New file.
---
...acemacs-rolling-release-add-data-dir.patch | 255 ++++++++++++++++++
...cs-rolling-release-inhibit-read-only.patch | 40 +++
...s-rolling-release-quelpa-permissions.patch | 51 ++++
gnu/packages/spacemacs.scm | 117 ++++++++
guix/build/spacemacs-utils.scm | 47 ++++
5 files changed, 510 insertions(+)
create mode 100644 gnu/packages/patches/spacemacs-rolling-release-add-data-dir.patch
create mode 100644 gnu/packages/patches/spacemacs-rolling-release-inhibit-read-only.patch
create mode 100644 gnu/packages/patches/spacemacs-rolling-release-quelpa-permissions.patch
create mode 100644 gnu/packages/spacemacs.scm
create mode 100644 guix/build/spacemacs-utils.scm
Toggle diff (348 lines)
diff --git a/gnu/packages/patches/spacemacs-rolling-release-add-data-dir.patch b/gnu/packages/patches/spacemacs-rolling-release-add-data-dir.patch
new file mode 100644
index 0000000000..74b35aec97
--- /dev/null
+++ b/gnu/packages/patches/spacemacs-rolling-release-add-data-dir.patch
@@ -0,0 +1,255 @@
+Spacemacs uses ~/.emacs.d in 2 ways: to store the code implementing the spacemacs framework and to track state. When we tell spacemacs that it lives in the store it tries to use the store location to track state as well. This patch adds a new variable, spacemacs-data-directory, for keeping track of state. This defaults to spacemacs-start-directory for upstream compatibility.
+
+diff --git a/core/core-configuration-layer.el b/core/core-configuration-layer.el
+index 740b700cf..c8253dc9b 100644
+--- a/core/core-configuration-layer.el
++++ b/core/core-configuration-layer.el
+@@ -120,7 +120,7 @@ subdirectory of ROOT is used."
+ "Hook executed at the end of configuration loading.")
+
+ (defconst configuration-layer--elpa-root-directory
+- (concat spacemacs-start-directory "elpa/")
++ (concat spacemacs-data-directory "elpa/")
+ "Spacemacs ELPA root directory.")
+
+ (defconst configuration-layer--rollback-root-directory
+diff --git a/core/core-documentation.el b/core/core-documentation.el
+index 96bfc4a87..3a3ef456d 100644
+--- a/core/core-documentation.el
++++ b/core/core-documentation.el
+@@ -289,7 +289,7 @@ preprocessors for the exported .org files."
+ });
+ });
+ </script>")
+- (publish-target (concat spacemacs-start-directory "export/"))
++ (publish-target (concat spacemacs-data-directory "export/"))
+ (org-html-htmlize-output-type 'css)
+ (org-publish-project-alist
+ `(("spacemacs"
+diff --git a/core/core-funcs.el b/core/core-funcs.el
+index 28e7290a5..2f09c1df7 100644
+--- a/core/core-funcs.el
++++ b/core/core-funcs.el
+@@ -274,7 +274,7 @@ result, incrementing passed-tests and total-tests."
+ (lambda (fname)
+ (when (file-exists-p fname)
+ (delete-file fname)))
+- (directory-files-recursively user-emacs-directory "\\.elc$" t)))
++ (directory-files-recursively spacemacs-data-directory "\\.elc$" t)))
+ (byte-recompile-directory package-user-dir 0 arg))
+
+ (defun spacemacs/register-repl (feature repl-func &optional tag)
+diff --git a/core/core-load-paths.el b/core/core-load-paths.el
+index 718b27ce4..90c0c28ad 100644
+--- a/core/core-load-paths.el
++++ b/core/core-load-paths.el
+@@ -19,6 +19,11 @@
+ (defvar spacemacs-start-directory
+ user-emacs-directory
+ "Spacemacs start directory.")
++(defvar spacemacs-data-directory
++ user-emacs-directory
++ "Writable directory for spacemacs data")
++(unless (file-exists-p spacemacs-data-directory)
++ (make-directory spacemacs-data-directory))
+ (defconst spacemacs-core-directory
+ (expand-file-name (concat spacemacs-start-directory "core/"))
+ "Spacemacs core directory.")
+@@ -45,7 +50,7 @@
+ (expand-file-name (concat spacemacs-banner-directory "img/heart.png"))
+ "Purple heart emoji.")
+ (defconst spacemacs-cache-directory
+- (expand-file-name (concat user-emacs-directory ".cache/"))
++ (expand-file-name (concat spacemacs-data-directory ".cache/"))
+ "Spacemacs storage area for persistent files")
+ (defconst spacemacs-auto-save-directory
+ (expand-file-name (concat spacemacs-cache-directory "auto-save/"))
+diff --git a/core/core-release-management.el b/core/core-release-management.el
+index 989ccb124..db0f5c76d 100644
+--- a/core/core-release-management.el
++++ b/core/core-release-management.el
+@@ -99,6 +99,10 @@ found."
+ (not (spacemacs//can-check-for-new-version-at-startup)))
+ (message (concat "Skipping check for new version "
+ "(reason: last check is too recent)")))
++ ((and (not force)
++ (or (string-prefix-p "/gnu/store" spacemacs-start-directory)
++ (string-prefix-p "/nix/store" spacemacs-start-directory)))
++ (message (concat "Skipping check for new version (reason: on guix or nix)")))
+ ((require 'async nil t)
+ (message "Start checking for new version...")
+ (async-start
+diff --git a/core/libs/quelpa.el b/core/libs/quelpa.el
+index 70b143657..9da420028 100644
+--- a/core/libs/quelpa.el
++++ b/core/libs/quelpa.el
+@@ -79,7 +79,7 @@ the `:upgrade' argument."
+ :group 'quelpa
+ :type 'hook)
+
+-(defcustom quelpa-dir (expand-file-name "quelpa" user-emacs-directory)
++(defcustom quelpa-dir (expand-file-name "quelpa" spacemacs-data-directory)
+ "Where quelpa builds and stores packages."
+ :group 'quelpa
+ :type 'string)
+diff --git a/tests/core/core-configuration-layer-utest.el b/tests/core/core-configuration-layer-utest.el
+index 0d300142b..e5877932c 100644
+--- a/tests/core/core-configuration-layer-utest.el
++++ b/tests/core/core-configuration-layer-utest.el
+@@ -880,16 +880,16 @@
+ (ert-deftest test-make-layer--make-layer-from-symbol-with-a-dir ()
+ (should (equal (cfgl-layer "layer"
+ :name 'layer
+- :dir spacemacs-start-directory)
++ :dir spacemacs-data-directory)
+ (configuration-layer/make-layer
+- 'layer nil nil spacemacs-start-directory))))
++ 'layer nil nil spacemacs-data-directory))))
+
+ (ert-deftest test-make-layer--make-layer-from-spec-with-a-dir ()
+ (should (equal (cfgl-layer "layer"
+ :name 'layer
+- :dir spacemacs-start-directory)
++ :dir spacemacs-data-directory)
+ (configuration-layer/make-layer
+- '(layer :name 'layer) nil nil spacemacs-start-directory))))
++ '(layer :name 'layer) nil nil spacemacs-data-directory))))
+
+ (ert-deftest test-make-layer--cannot-make-layer-without-a-directory ()
+ (mocker-let
+@@ -908,10 +908,10 @@
+ (ert-deftest test-make-layer--make-layer-without-a-dir-requires-an-initial-obj ()
+ (let ((layer (cfgl-layer "layer"
+ :name 'layer
+- :dir spacemacs-start-directory)))
++ :dir spacemacs-data-directory)))
+ (should (equal (cfgl-layer "layer"
+ :name 'layer
+- :dir spacemacs-start-directory)
++ :dir spacemacs-data-directory)
+ (configuration-layer/make-layer 'layer layer)))))
+
+ ;; load packages
+@@ -919,7 +919,7 @@
+ (ert-deftest test-make-layer--make-used-layer-loads-packages-file ()
+ (let ((layer (cfgl-layer "layer"
+ :name 'layer
+- :dir spacemacs-start-directory))
++ :dir spacemacs-data-directory))
+ (layer-packages '(pkg1 pkg2 pkg3))
+ (mocker-mock-default-record-cls 'mocker-stub-record))
+ (mocker-let
+@@ -931,13 +931,13 @@
+ :variables nil
+ :packages '(pkg1 pkg2 pkg3)
+ :selected-packages 'all
+- :dir spacemacs-start-directory)
++ :dir spacemacs-data-directory)
+ (configuration-layer/make-layer 'layer layer 'used))))))
+
+ (ert-deftest test-make-layer--make-layer-force-load-packages-file-with-var ()
+ (let ((layer (cfgl-layer "layer"
+ :name 'layer
+- :dir spacemacs-start-directory))
++ :dir spacemacs-data-directory))
+ (layer-packages '(pkg1 pkg2 pkg3))
+ (configuration-layer--load-packages-files t)
+ (mocker-mock-default-record-cls 'mocker-stub-record))
+@@ -950,13 +950,13 @@
+ :variables nil
+ :packages '(pkg1 pkg2 pkg3)
+ :selected-packages 'all
+- :dir spacemacs-start-directory)
++ :dir spacemacs-data-directory)
+ (configuration-layer/make-layer 'layer layer))))))
+
+ (ert-deftest test-make-layer--make-layer-does-not-load-packages-file-by-default ()
+ (let ((layer (cfgl-layer "layer"
+ :name 'layer
+- :dir spacemacs-start-directory))
++ :dir spacemacs-data-directory))
+ (layer-packages '(pkg1))
+ (mocker-mock-default-record-cls 'mocker-stub-record))
+ (mocker-let
+@@ -968,7 +968,7 @@
+ (ert-deftest test-make-layer--make-used-layer-can-set-additional-properties ()
+ (let ((layer (cfgl-layer "layer"
+ :name 'layer
+- :dir spacemacs-start-directory))
++ :dir spacemacs-data-directory))
+ (layer-specs '(layer :disabled-for pkg8 pkg9
+ :can-shadow layer2 layer3
+ :variables foo bar toto 1))
+@@ -984,13 +984,13 @@
+ :variables '(foo bar toto 1)
+ :packages '(pkg1 pkg2 pkg3)
+ :selected-packages 'all
+- :dir spacemacs-start-directory)
++ :dir spacemacs-data-directory)
+ (configuration-layer/make-layer layer-specs layer 'used))))))
+
+ (ert-deftest test-make-layer--make-not-used-layer-cannot-set-additional-properties ()
+ (let ((layer (cfgl-layer "layer"
+ :name 'layer
+- :dir spacemacs-start-directory))
++ :dir spacemacs-data-directory))
+ (layer-specs '(layer :disabled-for pkg8 pkg9
+ :can-shadow layer2
+ :variables foo bar toto 1))
+@@ -1002,7 +1002,7 @@
+ :variables nil
+ :packages nil
+ :selected-packages 'all
+- :dir spacemacs-start-directory)
++ :dir spacemacs-data-directory)
+ (configuration-layer/make-layer layer-specs layer)))))
+
+ (ert-deftest test-make-layer--make-used-layer-can-override-additional-properties ()
+@@ -1011,7 +1011,7 @@
+ :disabled-for '(pkg10)
+ :can-shadow '()
+ :variables '(titi tata tutu 1)
+- :dir spacemacs-start-directory))
++ :dir spacemacs-data-directory))
+ (layer-specs '(layer :disabled-for pkg8 pkg9
+ :can-shadow layer2
+ :variables foo bar toto 1))
+@@ -1027,7 +1027,7 @@
+ :variables '(foo bar toto 1)
+ :packages '(pkg1 pkg2 pkg3)
+ :selected-packages 'all
+- :dir spacemacs-start-directory)
++ :dir spacemacs-data-directory)
+ (configuration-layer/make-layer layer-specs layer 'used))))))
+
+ (ert-deftest test-make-layer--make-not-used-layer-cannot-override-additional-properties ()
+@@ -1038,7 +1038,7 @@
+ :variables '(titi tata tutu 1)
+ :packages '(pkg1 pkg2 pkg3)
+ :selected-packages 'all
+- :dir spacemacs-start-directory))
++ :dir spacemacs-data-directory))
+ (layer-specs '(layer :disabled-for pkg8 pkg9
+ :can-shadow '(layer2)
+ :variables foo bar toto 1))
+@@ -1050,7 +1050,7 @@
+ :variables '(titi tata tutu 1)
+ :packages '(pkg1 pkg2 pkg3)
+ :selected-packages 'all
+- :dir spacemacs-start-directory)
++ :dir spacemacs-data-directory)
+ (configuration-layer/make-layer layer-specs layer)))))
+
+ ;; ---------------------------------------------------------------------------
+diff --git a/tests/doc/org-export-ftest.el b/tests/doc/org-export-ftest.el
+index 4ee86c897..cdd731eec 100644
+--- a/tests/doc/org-export-ftest.el
++++ b/tests/doc/org-export-ftest.el
+@@ -59,6 +59,6 @@
+ ;; -----------------------------------------------------------------------------
+ (ert-deftest test-spacemacs-html-export ()
+ (unwind-protect (spacemacs/publish-doc)
+- (delete-directory (concat spacemacs-start-directory
++ (delete-directory (concat spacemacs-data-directory
+ "export/")
+ t)))
diff --git a/gnu/packages/patches/spacemacs-rolling-release-inhibit-read-only.patch b/gnu/packages/patches/spacemacs-rolling-release-inhibit-read-only.patch
new file mode 100644
index 0000000000..71d3858696
--- /dev/null
+++ b/gnu/packages/patches/spacemacs-rolling-release-inhibit-read-only.patch
@@ -0,0 +1,40 @@
+The first time that a user runs spacemacs it will open the default configuration from the source tree and modify the buffer. The buffer is read-only since the file it opened is, but since we save the file to the users home directory and not back to it's original location temporarily inhibiting read-only solves our problem.
+
+diff --git a/core/core-dotspacemacs.el b/core/core-dotspacemacs.el
+index f28249148..3b7872ff0 100644
+--- a/core/core-dotspacemacs.el
++++ b/core/core-dotspacemacs.el
+@@ -643,19 +643,20 @@ If ARG is non nil then Ask questions to the user before installing the dotfile."
+ (with-current-buffer (find-file-noselect
+ (concat dotspacemacs-template-directory
+ ".spacemacs.template"))
+- (dolist (p preferences)
+- (goto-char (point-min))
+- (re-search-forward (car p))
+- (replace-match (cadr p)))
+- (let ((install
+- (if (file-exists-p dotspacemacs-filepath)
+- (y-or-n-p
+- (format "%s already exists. Do you want to overwrite it ? "
+- dotspacemacs-filepath)) t)))
+- (when install
+- (write-file dotspacemacs-filepath)
+- (message "%s has been installed." dotspacemacs-filepath)
+- t))))
++ (let ((inhibit-read-only t))
++ (dolist (p preferences)
++ (goto-char (point-min))
++ (re-search-forward (car p))
++ (replace-match (cadr p)))
++ (let ((install
++ (if (file-exists-p dotspacemacs-filepath)
++ (y-or-n-p
++ (format "%s already exists. Do you want to overwrite it ? "
++ dotspacemacs-filepath)) t)))
++ (when install
++ (write-file dotspacemacs-filepath)
++ (message "%s has been installed." dotspacemacs-filepath)
++ t)))))
+ (dotspacemacs/load-file)
+ ;; force new wizard values to be applied
+ (dotspacemacs/init))
diff --git a/gnu/packages/patches/spacemacs-rolling-release-quelpa-permissions.patch b/gnu/packages/patches/spacemacs-rolling-release-quelpa-permissions.patch
new file mode 100644
index 0000000000..b3b514941f
--- /dev/null
+++ b/gnu/packages/patches/spacemacs-rolling-release-quelpa-permissions.patch
@@ -0,0 +1,51 @@
+When quelpa builds some packages it has to copy files from the store, which means that they are marked as read-only. This patch sets the permissions of copied files and directories to ensure that they are writable.
+
+diff --git a/core/libs/quelpa.el b/core/libs/quelpa.el
+index 70b143657..9da420028 100644
+@@ -374,8 +374,10 @@ and return TIME-STAMP, otherwise return OLD-TIME-STAMP."
+ (delete-directory dir t)
+ (make-directory dir)
+ (if (eq type 'file)
+- (copy-file file-path dir t t t t)
+- (copy-directory file-path dir t t t)))
++ (progn (copy-file file-path dir t t t t)
++ (set-file-modes (expand-file-name (file-name-nondirectory file-path) dir) #o644))
++ (progn (copy-directory file-path dir t t t)
++ (set-file-modes dir #o755))))
+ (quelpa-build--dump new-stamp-info stamp-file)
+ (quelpa-file-version file-path type version time-stamp))))
+
+@@ -1369,10 +1371,13 @@ FILES is a list of (SOURCE . DEST) relative filepath pairs."
+ (cond
+ ((file-regular-p file)
+ (quelpa-build--message "%s -> %s" file newname)
+- (copy-file file newname))
++ (copy-file file newname)
++ (set-file-modes newname #o644))
+ ((file-directory-p file)
+ (quelpa-build--message "%s => %s" file newname)
+- (copy-directory file newname))))
++ (make-directory newname)
++ (set-file-modes newname #o755)
++ (map quelpa-build--copy-file (directory-files file t)))))
+
+ (defun quelpa-build--find-source-file (target files)
+ "Search for source of TARGET in FILES."
+@@ -1463,6 +1468,7 @@ Returns the archive entry for the package."
+ (if (file-exists-p pkg-
This message was truncated. Download the full message here.