unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Liliana Marie Prikler <liliana.prikler@gmail.com>
To: "(" <paren@disroot.org>, 58693@debbugs.gnu.org
Cc: control@debbugs.gnu.org
Subject: [bug#58693] [PATCH 1/1] gnu: home: Add home-emacs-service-type.
Date: Sat, 22 Oct 2022 11:41:43 +0200	[thread overview]
Message-ID: <9c453dd100e4d66d458a217f448c0b2362adc2f2.camel@gmail.com> (raw)
In-Reply-To: <20221021192458.4956-1-paren@disroot.org>

merge 58693 58652
thanks

Am Freitag, dem 21.10.2022 um 20:24 +0100 schrieb (:
> +(define-configuration/no-serialization home-emacs-configuration
> +  (emacs
> +   (file-like emacs)
> +   "The package providing @file{/bin/emacs}.")
> +  (packages
> +   (list-of-file-likes '())
> +   "Packages to add to the Emacs plugin load path.")
> +  (native-compile?
> +   (boolean #f)
> +   "Whether to compile the @code{packages} using the Emacs package
> +provided as the value of the @code{emacs} field, which will enable
> +native compilation if the @code{emacs} package supports it.")
> +  (init-file
> +   (file-like (plain-file "init.el" ""))
> +   "File-like to use as the initialisation Lisp file.")
> +  (early-init-file
> +   (file-like (plain-file "early-init.el" ""))
> +   "File-like to use as the pre-initialisation Lisp file.")
> +  (debug?
> +   (boolean #f)
> +   "Whether to enable debugging."))
> +
> +(define (home-emacs-profile-packages config)
> +  (list (home-emacs-configuration-emacs config)))
> +
> +(define (home-emacs-transformed-packages config)
> +  (map (if (home-emacs-configuration-native-compile? config)
> +           (package-input-rewriting
> +            `((,emacs-minimal
> +              . ,(home-emacs-configuration-emacs config))))
> +           identity)
> +       (let ((packages (home-emacs-configuration-packages config)))
> +         (concatenate
> +          (cons packages
> +                (map (compose (cute map second <>)
> +                              package-transitive-propagated-inputs)
> +                     packages))))))
> +
> +(define (home-emacs-shepherd-services config)
> +  (list (shepherd-service
> +         (provision '(emacs))
> +         (documentation "Start the Emacs daemon.")
> +         (modules '((ice-9 ftw)
> +                    (srfi srfi-1)
> +                    (srfi srfi-26)))
> +         (start
> +          #~(make-forkexec-constructor
> +             (list #$(file-append
> +                      (home-emacs-configuration-emacs config)
> +                      "/bin/emacs")
> +                   "--fg-daemon" "--eval"
You should probably use a systemd-style constructor/destructor pair.

> +                   (format #f "~s"
> +                           `(progn
> +                             (setq custom-file
> +                                   (concat (or (getenv
> "XDG_CONFIG_HOME")
> +                                               (concat (getenv
> "HOME")
> +                                                       "/.config"))
> +                                           "/emacs/custom.el"))
> +                             (load custom-file)))
This one should be customizable by the user using init.el or early-
init.el -- alternatively, you could set up a custom-file parameter and
use that *if given*.

> +                   #$@(if (home-emacs-configuration-debug? config)
> +                          (list "--debug-init")
> +                          '()))
> +             #:log-file
> +             (format #f "~a/emacs.log"
> +                     (or (getenv "XDG_LOG_HOME")
> +                         (format #f "~a/.local/var/log"
> +                                 (getenv "HOME"))))
XDG_LOG_HOME and ~/.local/var are guix home idiosyncrasies that ought
to be removed.  The XDG-supported variable/value pair is XDG_STATE_HOME
and ~/.local/state.

> +             #:environment-variables
> +             (let ((env-var
> +                    (lambda (name path)
> +                      (define (regular-directory? directory)
> +                        (not (member directory (list "." ".."))))
> +
> +                      (define (package-paths package)
> +                        (let ((directory (string-append package "/"
> path)))
> +                          (if (file-exists? directory)
> +                              (cons directory
> +                                    (map (cute string-append
> directory "/" <>)
> +                                         (scandir directory regular-
> directory?)))
> +                              '())))
> +
> +                      (let ((old-value (getenv name)))
> +                        (string-append
> +                         name "="
> +                         (string-join
> +                          (append-map
> +                           package-paths
> +                           (list #$@(home-emacs-transformed-packages
> config)))
> +                          ":" (if old-value
> +                                  'suffix
> +                                  'infix))
> +                         (or old-value ""))))))
> +               (append (default-environment-variables)
> +                       (list (env-var "EMACSLOADPATH"
> +                                      "share/emacs/site-lisp")
> +                             (env-var "EMACSNATIVELOADPATH"
> +                                      "lib/emacs/native-site-
> lisp"))))))
You should collect the emacs package plus lisp packages into a profile.
This will make it easier to set emacs-related variables. 
Alternatively, you could use (guix search-paths) directly.

> +         (stop
> +          #~(make-forkexec-constructor
> +             (list #$(file-append
> +                      (home-emacs-configuration-emacs config)
> +                      "/bin/emacsclient")
> +                   "--eval" "(kill-emacs)"))))))
> +
> +(define (home-emacs-xdg-configuration-files config)
> +  `(("emacs/early-init.el"
> +     ,(home-emacs-configuration-early-init-file config))
> +    ("emacs/init.el"
> +     ,(home-emacs-configuration-init-file config))))
You're missing an escape hatch for additional elisp files like
custom.el

Cheers

  reply	other threads:[~2022-10-22 11:07 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-21 19:23 [bug#58693] [PATCH 0/1] gnu: home: Add home-emacs-service-type ( via Guix-patches via
2022-10-21 19:24 ` [bug#58693] [PATCH 1/1] " ( via Guix-patches via
2022-10-22  9:41   ` Liliana Marie Prikler [this message]
2022-11-08 12:59   ` [bug#58693] [PATCH 0/1] " Ludovic Courtès
2022-11-08 16:30     ` ( via Guix-patches via

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9c453dd100e4d66d458a217f448c0b2362adc2f2.camel@gmail.com \
    --to=liliana.prikler@gmail.com \
    --cc=58693@debbugs.gnu.org \
    --cc=control@debbugs.gnu.org \
    --cc=paren@disroot.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).