unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Creating an Emacs Home Configuration Service
@ 2022-10-17  2:34 ` Zain Jabbar
  2022-10-17 22:09   ` jbranso
                     ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Zain Jabbar @ 2022-10-17  2:34 UTC (permalink / raw)
  To: guix-devel

[-- Attachment #1: Type: text/plain, Size: 4437 bytes --]

Aloha Guix Development Team,

Running =guix home search emacs= returns nothing. I also could not find an
email using =C-u M-x debbugs-gnu= about an Emacs configuration service.

This is my first email to this mailing address. Please give me pointers on
formatting and further improvements.

I have attempted to make an =emacs-home-service-type= so that it is
possible to configure Emacs using Guix home. This code is extremely
preliminary hence I don't even think it is worth sending as a patch. Also I
have never worked on a multi person Git project before and do not know how
to solve the keyring error I get when using guix pull. I will outline what
my code does and what features I would like to add.

#+BEGIN_SRC scheme
(define* (emacs-configuration-service name #:key (init '()) (early-init
'()) (emacs-packages '()))
  (service-type (name (symbol-append 'emacs- name '-configuration))
(extensions
(list (service-extension
home-profile-service-type
(lambda (config) emacs-packages))
      (service-extension
home-files-service-type
(lambda (config)
 (list
  `(,(string-append
      ".config/emacs/services/" (symbol->string name) ".el")
    ,(scheme-file (string-append (symbol->string name) ".el")
  init #:splice? #t))
  `(,(string-append
      ".config/emacs/early-services/" (symbol->string name) ".el")
    ,(scheme-file (string-append "early-" (symbol->string name) ".el")
  early-init #:splice? #t)))))))
(default-value #f)
(description "Configures Emacs init.el")))


(define-public emacs-init-service-type
  (service-type (name 'home-emacs)
(extensions
(list (service-extension
home-profile-service-type
(lambda (config) (list emacs-next)))
      (service-extension
home-files-service-type
(lambda (config)
 (list
  `(".config/emacs/early-init.el"
    ,(scheme-file
      "early-init.el"
      '((mapc
 'load (file-expand-wildcards
"~/.config/emacs/early-services/*.el")))
      #:splice? #t))
  `(".config/emacs/init.el"
    ,(scheme-file
      "init.el"
      '((mapc
 'load (file-expand-wildcards
"~/.config/emacs/services/*.el")))
      #:splice? #t)))))))
(default-value #f)
(description "Configures Emacs init.el")))
#+END_SRC

I define a general configuration service generator which takes in four
things:
1. The =name= of the service
2. The configuration to be ran in =init.el=
3. The configuration to be ran in =early-init.el=
4. The packages in Guix to be added to the =home-profile=.

After giving the =name=, =packages=, and =config.el= files we get a new
service type that we can add to our home declaration. This service will
then add a file in
=~/.config/emacs/services/emacs-{NAME}-configuration.el=. I then have
another service that places an =init.el= which loads everything in the
service directory.

If we want to install and configure =evil-mode= using this =home-service=
we may define the following somewhere.

#+BEGIN_SRC scheme
(define-public emacs-evil-service-type
  (emacs-configuration-service
   'evil #:emacs-packages (list emacs-evil)
   #:init '((evil-mode 1))))
#+END_SRC

Within our =home-environment= we may add the service using:

#+BEGIN_SRC scheme
(home-environment
 ;; ...Things in the home-environment...
 (services
  (list
   ;; ...Other Services...
   (service emacs-evil-service-type))))
#+END_SRC

There are some missing features I want to add.

1. Have the =home-emacs-*-service-type= service-types add to the =init.el=
directly rather than within a folder to be loaded. I couldn't add two files
with the same name to the store. So I have emacs-evil.el in the store to be
placed separately later rather than appending to the existing init.el file.

2. Have Emacs update whenever the =home-environment= is updated. Meaning,
if I did not add =(service emacs-evil-service-type)= in my
=home-environment= then obviously =M-x evil-mode= should not work. But
after adding the service then I want =M-x evil-mode= to work without having
to restart Emacs. I do not understand the Emacs loading system on Guix well
enough to know why it does not work. Skipping all of the =home-service=
stuff, running =guix install emacs-evil-mode= then
=(guix-emacs-autoload-packages)= does not let emacs know that =evil-mode=
is installed. I would need to close Emacs and start Emacs again for Emacs
to know about =evil-mode= being installed.

3. Use configurations somehow. I have completely neglected this feature in
my system. I do not know what would be useful there.

-- 
Thank you,
Zain Jabbar

[-- Attachment #2: Type: text/html, Size: 5425 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Creating an Emacs Home Configuration Service
  2022-10-17  2:34 ` Creating an Emacs Home Configuration Service Zain Jabbar
@ 2022-10-17 22:09   ` jbranso
  2022-10-17 23:12     ` Zain Jabbar
  2022-10-18 15:41     ` jbranso
  2022-10-19 15:36   ` Ludovic Courtès
  2022-10-20 18:35   ` Liliana Marie Prikler
  2 siblings, 2 replies; 13+ messages in thread
From: jbranso @ 2022-10-17 22:09 UTC (permalink / raw)
  To: Zain Jabbar, guix-devel

October 17, 2022 2:38 AM, "Zain Jabbar" <zaijab2000@gmail.com> wrote:

> Aloha Guix Development Team,
> 
> Running =guix home search emacs= returns nothing. I also could not find an email using =C-u M-x
> debbugs-gnu= about an Emacs configuration service.
> 
> This is my first email to this mailing address. Please give me pointers on formatting and further
> improvements.

I think you sent an html email.  Generally you want to send plain text emails.  :)
 
> I have attempted to make an =emacs-home-service-type= so that it is possible to configure Emacs
> using Guix home. This code is extremely preliminary hence I don't even think it is worth sending as
> a patch. Also I have never worked on a multi person Git project before and do not know how to solve
> the keyring error I get when using guix pull. I will outline what my code does and what features I
> would like to add.
> 
> #+BEGIN_SRC scheme
> (define* (emacs-configuration-service name #:key (init '()) (early-init '()) (emacs-packages '()))
> (service-type (name (symbol-append 'emacs- name '-configuration))
> (extensions
> (list (service-extension
> home-profile-service-type
> (lambda (config) emacs-packages))
> (service-extension
> home-files-service-type
> (lambda (config)
> (list
> `(,(string-append
> ".config/emacs/services/" (symbol->string name) ".el")
> ,(scheme-file (string-append (symbol->string name) ".el")
> init #:splice? #t))
> `(,(string-append
> ".config/emacs/early-services/" (symbol->string name) ".el")
> ,(scheme-file (string-append "early-" (symbol->string name) ".el")
> early-init #:splice? #t)))))))
> (default-value #f)
> (description "Configures Emacs init.el")))
> 
> (define-public emacs-init-service-type
> (service-type (name 'home-emacs)
> (extensions
> (list (service-extension
> home-profile-service-type
> (lambda (config) (list emacs-next)))
> (service-extension
> home-files-service-type
> (lambda (config)
> (list
> `(".config/emacs/early-init.el"
> ,(scheme-file
> "early-init.el"
> '((mapc
> 'load (file-expand-wildcards
> "~/.config/emacs/early-services/*.el")))
> #:splice? #t))
> `(".config/emacs/init.el"
> ,(scheme-file
> "init.el"
> '((mapc
> 'load (file-expand-wildcards
> "~/.config/emacs/services/*.el")))
> #:splice? #t)))))))
> (default-value #f)
> (description "Configures Emacs init.el")))
> #+END_SRC
> 
> I define a general configuration service generator which takes in four things:
> 1. The =name= of the service
> 2. The configuration to be ran in =init.el=
> 3. The configuration to be ran in =early-init.el=
> 4. The packages in Guix to be added to the =home-profile=.
> 
> After giving the =name=, =packages=, and =config.el= files we get a new service type that we can
> add to our home declaration. This service will then add a file in
> =~/.config/emacs/services/emacs-{NAME}-configuration.el=. I then have another service that places
> an =init.el= which loads everything in the service directory.
> 
> If we want to install and configure =evil-mode= using this =home-service= we may define the
> following somewhere.
> 
> #+BEGIN_SRC scheme
> (define-public emacs-evil-service-type
> (emacs-configuration-service
> 'evil #:emacs-packages (list emacs-evil)
> #:init '((evil-mode 1))))
> #+END_SRC
> 
> Within our =home-environment= we may add the service using:
> 
> #+BEGIN_SRC scheme
> (home-environment
> ;; ...Things in the home-environment...
> (services
> (list
> ;; ...Other Services...
> (service emacs-evil-service-type))))
> #+END_SRC
> 
> There are some missing features I want to add.
> 
> 1. Have the =home-emacs-*-service-type= service-types add to the =init.el= directly rather than
> within a folder to be loaded. I couldn't add two files with the same name to the store. So I have
> emacs-evil.el in the store to be placed separately later rather than appending to the existing
> init.el file.
> 
> 2. Have Emacs update whenever the =home-environment= is updated. Meaning, if I did not add
> =(service emacs-evil-service-type)= in my =home-environment= then obviously =M-x evil-mode= should
> not work. But after adding the service then I want =M-x evil-mode= to work without having to
> restart Emacs. I do not understand the Emacs loading system on Guix well enough to know why it does
> not work. Skipping all of the =home-service= stuff, running =guix install emacs-evil-mode= then
> =(guix-emacs-autoload-packages)= does not let emacs know that =evil-mode= is installed. I would
> need to close Emacs and start Emacs again for Emacs to know about =evil-mode= being installed.
> 
> 3. Use configurations somehow. I have completely neglected this feature in my system. I do not know
> what would be useful there.

I believe that you are referring to using scheme records to configure the emacs service.  :)

I would recommend using (define-configuration ...) procedure.

(There is a define-record-type* as well, but I think the consensus is that 
define-configuration* is a little easier to use.  Does better error handling
and can help you generate documentation from the code).

You can find examples of that here:

https://git.savannah.gnu.org/cgit/guix.git/tree/gnu/services/mail.scm

> 
> --
> Thank you,
> Zain Jabbar


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Creating an Emacs Home Configuration Service
  2022-10-17 22:09   ` jbranso
@ 2022-10-17 23:12     ` Zain Jabbar
  2022-10-18 15:41     ` jbranso
  1 sibling, 0 replies; 13+ messages in thread
From: Zain Jabbar @ 2022-10-17 23:12 UTC (permalink / raw)
  To: jbranso; +Cc: guix-devel

Aloha Guix Development Team,

Thank you for this email. Your advice was directed very kindly and is
very helpful. I have tried to revise the code based on your email. I
also checked the setting for plaintext mode in GMail; I hope this
makes the email easier to read.

First, I define a configuration (without serialization currently).

#+BEGIN_SRC scheme
(define file-likes? (list-of file-like?))

(define-configuration/no-serialization emacs-configuration
  (emacs-packages
   (file-likes (list (specification->package "emacs-next"))) "Files")
  (early-init
   (list '()) "Early-Init")
  (init
   (list '()) "Init"))
#+END_SRC

Then, I define an =emacs-configuration-service= that takes in a
configuration. This service will add packages in the =emacs-packages=
to the profile, and append the S-Expressions in =early-init= and
=init= to $XDG_CONFIG_HOME/emacs/early-init.el and
$XDG_CONFIG_HOME/emacs/init.el respectively. The service has
definition,

#+BEGIN_SRC scheme
(define-public emacs-configuration-service
  (service-type (name (symbol-append 'emacs-configuration))
(extensions
(list (service-extension
home-profile-service-type
(lambda (config) (emacs-configuration-emacs-packages config)))
       (service-extension
home-xdg-configuration-files-service-type
(lambda (config)
  (list
   `("emacs/init.el" ,(scheme-file "init.el"
  (emacs-configuration-init config)
  #:splice? #:t))
   `("emacs/early-init.el" ,(scheme-file "early-init.el"
  (emacs-configuration-early-init config)
  #:splice? #:t)))))))
(default-value (emacs-configuration))
(description "Configures Emacs init.el")))
#+END_SRC

This version of the service is one big service that only takes in one
configuration file. So in order to configure bits and pieces of Emacs,
for example evil-mode and vertico we can append emacs-configurations
into one big configuration. I do this as follows.

#+BEGIN_SRC scheme
(define evil-configuration
  (emacs-configuration
   (emacs-packages (list (specification->package "emacs-evil")))
   (init '((evil-mode 1)))))

(define vertico-configuration
  (emacs-configuration
   (emacs-packages (list (specification->package "emacs-vertico")))
   (init '((vertico-mode 1)))))

(define-public total-emacs-configuration
  (fold (lambda (config-1 config-2) (emacs-configuration
     (init (append (emacs-configuration-init config-1)
   (emacs-configuration-init config-2)))
     (early-init (append (emacs-configuration-early-init config-1)
(emacs-configuration-early-init config-2)))
     (emacs-packages (append (emacs-configuration-emacs-packages config-1)
     (emacs-configuration-emacs-packages config-2)))))
(emacs-configuration)
(list evil-configuration vertico-configuration)))
#+END_SRC

We can actually go crazy with this idea. The next source block is a
generalization of the last one. Rather than declaring the list of
configurations, we have Guile figure out all of the bound
=emacs-configurations= in the current module and append them that way.

#+BEGIN_SRC scheme
(define-public total-emacs-configuration
  (fold (lambda (config-1 config-2) (emacs-configuration
     (init (append (emacs-configuration-init config-1)
   (emacs-configuration-init config-2)))
     (early-init (append (emacs-configuration-early-init config-1)
(emacs-configuration-early-init config-2)))
     (emacs-packages (append (emacs-configuration-emacs-packages config-1)
     (emacs-configuration-emacs-packages config-2)))))
(emacs-configuration)

(filter emacs-configuration?
(map variable-ref
     (filter variable-bound?
     (hash-map->list (lambda (x y) y) (struct-ref (current-module) 0)))))))
#+END_SRC

What further improvements could I add to this system? The end goal
(hopefully) is to help add another home service to Guix. I was
inspired by David Wilson's call to action during his Guix Home talk at
the 10 year anniversary event.



On Mon, Oct 17, 2022 at 12:09 PM <jbranso@dismail.de> wrote:
>
> October 17, 2022 2:38 AM, "Zain Jabbar" <zaijab2000@gmail.com> wrote:
>
> > Aloha Guix Development Team,
> >
> > Running =guix home search emacs= returns nothing. I also could not find an email using =C-u M-x
> > debbugs-gnu= about an Emacs configuration service.
> >
> > This is my first email to this mailing address. Please give me pointers on formatting and further
> > improvements.
>
> I think you sent an html email.  Generally you want to send plain text emails.  :)
>
> > I have attempted to make an =emacs-home-service-type= so that it is possible to configure Emacs
> > using Guix home. This code is extremely preliminary hence I don't even think it is worth sending as
> > a patch. Also I have never worked on a multi person Git project before and do not know how to solve
> > the keyring error I get when using guix pull. I will outline what my code does and what features I
> > would like to add.
> >
> > #+BEGIN_SRC scheme
> > (define* (emacs-configuration-service name #:key (init '()) (early-init '()) (emacs-packages '()))
> > (service-type (name (symbol-append 'emacs- name '-configuration))
> > (extensions
> > (list (service-extension
> > home-profile-service-type
> > (lambda (config) emacs-packages))
> > (service-extension
> > home-files-service-type
> > (lambda (config)
> > (list
> > `(,(string-append
> > ".config/emacs/services/" (symbol->string name) ".el")
> > ,(scheme-file (string-append (symbol->string name) ".el")
> > init #:splice? #t))
> > `(,(string-append
> > ".config/emacs/early-services/" (symbol->string name) ".el")
> > ,(scheme-file (string-append "early-" (symbol->string name) ".el")
> > early-init #:splice? #t)))))))
> > (default-value #f)
> > (description "Configures Emacs init.el")))
> >
> > (define-public emacs-init-service-type
> > (service-type (name 'home-emacs)
> > (extensions
> > (list (service-extension
> > home-profile-service-type
> > (lambda (config) (list emacs-next)))
> > (service-extension
> > home-files-service-type
> > (lambda (config)
> > (list
> > `(".config/emacs/early-init.el"
> > ,(scheme-file
> > "early-init.el"
> > '((mapc
> > 'load (file-expand-wildcards
> > "~/.config/emacs/early-services/*.el")))
> > #:splice? #t))
> > `(".config/emacs/init.el"
> > ,(scheme-file
> > "init.el"
> > '((mapc
> > 'load (file-expand-wildcards
> > "~/.config/emacs/services/*.el")))
> > #:splice? #t)))))))
> > (default-value #f)
> > (description "Configures Emacs init.el")))
> > #+END_SRC
> >
> > I define a general configuration service generator which takes in four things:
> > 1. The =name= of the service
> > 2. The configuration to be ran in =init.el=
> > 3. The configuration to be ran in =early-init.el=
> > 4. The packages in Guix to be added to the =home-profile=.
> >
> > After giving the =name=, =packages=, and =config.el= files we get a new service type that we can
> > add to our home declaration. This service will then add a file in
> > =~/.config/emacs/services/emacs-{NAME}-configuration.el=. I then have another service that places
> > an =init.el= which loads everything in the service directory.
> >
> > If we want to install and configure =evil-mode= using this =home-service= we may define the
> > following somewhere.
> >
> > #+BEGIN_SRC scheme
> > (define-public emacs-evil-service-type
> > (emacs-configuration-service
> > 'evil #:emacs-packages (list emacs-evil)
> > #:init '((evil-mode 1))))
> > #+END_SRC
> >
> > Within our =home-environment= we may add the service using:
> >
> > #+BEGIN_SRC scheme
> > (home-environment
> > ;; ...Things in the home-environment...
> > (services
> > (list
> > ;; ...Other Services...
> > (service emacs-evil-service-type))))
> > #+END_SRC
> >
> > There are some missing features I want to add.
> >
> > 1. Have the =home-emacs-*-service-type= service-types add to the =init.el= directly rather than
> > within a folder to be loaded. I couldn't add two files with the same name to the store. So I have
> > emacs-evil.el in the store to be placed separately later rather than appending to the existing
> > init.el file.
> >
> > 2. Have Emacs update whenever the =home-environment= is updated. Meaning, if I did not add
> > =(service emacs-evil-service-type)= in my =home-environment= then obviously =M-x evil-mode= should
> > not work. But after adding the service then I want =M-x evil-mode= to work without having to
> > restart Emacs. I do not understand the Emacs loading system on Guix well enough to know why it does
> > not work. Skipping all of the =home-service= stuff, running =guix install emacs-evil-mode= then
> > =(guix-emacs-autoload-packages)= does not let emacs know that =evil-mode= is installed. I would
> > need to close Emacs and start Emacs again for Emacs to know about =evil-mode= being installed.
> >
> > 3. Use configurations somehow. I have completely neglected this feature in my system. I do not know
> > what would be useful there.
>
> I believe that you are referring to using scheme records to configure the emacs service.  :)
>
> I would recommend using (define-configuration ...) procedure.
>
> (There is a define-record-type* as well, but I think the consensus is that
> define-configuration* is a little easier to use.  Does better error handling
> and can help you generate documentation from the code).
>
> You can find examples of that here:
>
> https://git.savannah.gnu.org/cgit/guix.git/tree/gnu/services/mail.scm
>
> >
> > --
> > Thank you,
> > Zain Jabbar



--
Thank you,
Zain Jabbar

On Mon, Oct 17, 2022 at 12:09 PM <jbranso@dismail.de> wrote:
>
> October 17, 2022 2:38 AM, "Zain Jabbar" <zaijab2000@gmail.com> wrote:
>
> > Aloha Guix Development Team,
> >
> > Running =guix home search emacs= returns nothing. I also could not find an email using =C-u M-x
> > debbugs-gnu= about an Emacs configuration service.
> >
> > This is my first email to this mailing address. Please give me pointers on formatting and further
> > improvements.
>
> I think you sent an html email.  Generally you want to send plain text emails.  :)
>
> > I have attempted to make an =emacs-home-service-type= so that it is possible to configure Emacs
> > using Guix home. This code is extremely preliminary hence I don't even think it is worth sending as
> > a patch. Also I have never worked on a multi person Git project before and do not know how to solve
> > the keyring error I get when using guix pull. I will outline what my code does and what features I
> > would like to add.
> >
> > #+BEGIN_SRC scheme
> > (define* (emacs-configuration-service name #:key (init '()) (early-init '()) (emacs-packages '()))
> > (service-type (name (symbol-append 'emacs- name '-configuration))
> > (extensions
> > (list (service-extension
> > home-profile-service-type
> > (lambda (config) emacs-packages))
> > (service-extension
> > home-files-service-type
> > (lambda (config)
> > (list
> > `(,(string-append
> > ".config/emacs/services/" (symbol->string name) ".el")
> > ,(scheme-file (string-append (symbol->string name) ".el")
> > init #:splice? #t))
> > `(,(string-append
> > ".config/emacs/early-services/" (symbol->string name) ".el")
> > ,(scheme-file (string-append "early-" (symbol->string name) ".el")
> > early-init #:splice? #t)))))))
> > (default-value #f)
> > (description "Configures Emacs init.el")))
> >
> > (define-public emacs-init-service-type
> > (service-type (name 'home-emacs)
> > (extensions
> > (list (service-extension
> > home-profile-service-type
> > (lambda (config) (list emacs-next)))
> > (service-extension
> > home-files-service-type
> > (lambda (config)
> > (list
> > `(".config/emacs/early-init.el"
> > ,(scheme-file
> > "early-init.el"
> > '((mapc
> > 'load (file-expand-wildcards
> > "~/.config/emacs/early-services/*.el")))
> > #:splice? #t))
> > `(".config/emacs/init.el"
> > ,(scheme-file
> > "init.el"
> > '((mapc
> > 'load (file-expand-wildcards
> > "~/.config/emacs/services/*.el")))
> > #:splice? #t)))))))
> > (default-value #f)
> > (description "Configures Emacs init.el")))
> > #+END_SRC
> >
> > I define a general configuration service generator which takes in four things:
> > 1. The =name= of the service
> > 2. The configuration to be ran in =init.el=
> > 3. The configuration to be ran in =early-init.el=
> > 4. The packages in Guix to be added to the =home-profile=.
> >
> > After giving the =name=, =packages=, and =config.el= files we get a new service type that we can
> > add to our home declaration. This service will then add a file in
> > =~/.config/emacs/services/emacs-{NAME}-configuration.el=. I then have another service that places
> > an =init.el= which loads everything in the service directory.
> >
> > If we want to install and configure =evil-mode= using this =home-service= we may define the
> > following somewhere.
> >
> > #+BEGIN_SRC scheme
> > (define-public emacs-evil-service-type
> > (emacs-configuration-service
> > 'evil #:emacs-packages (list emacs-evil)
> > #:init '((evil-mode 1))))
> > #+END_SRC
> >
> > Within our =home-environment= we may add the service using:
> >
> > #+BEGIN_SRC scheme
> > (home-environment
> > ;; ...Things in the home-environment...
> > (services
> > (list
> > ;; ...Other Services...
> > (service emacs-evil-service-type))))
> > #+END_SRC
> >
> > There are some missing features I want to add.
> >
> > 1. Have the =home-emacs-*-service-type= service-types add to the =init.el= directly rather than
> > within a folder to be loaded. I couldn't add two files with the same name to the store. So I have
> > emacs-evil.el in the store to be placed separately later rather than appending to the existing
> > init.el file.
> >
> > 2. Have Emacs update whenever the =home-environment= is updated. Meaning, if I did not add
> > =(service emacs-evil-service-type)= in my =home-environment= then obviously =M-x evil-mode= should
> > not work. But after adding the service then I want =M-x evil-mode= to work without having to
> > restart Emacs. I do not understand the Emacs loading system on Guix well enough to know why it does
> > not work. Skipping all of the =home-service= stuff, running =guix install emacs-evil-mode= then
> > =(guix-emacs-autoload-packages)= does not let emacs know that =evil-mode= is installed. I would
> > need to close Emacs and start Emacs again for Emacs to know about =evil-mode= being installed.
> >
> > 3. Use configurations somehow. I have completely neglected this feature in my system. I do not know
> > what would be useful there.
>
> I believe that you are referring to using scheme records to configure the emacs service.  :)
>
> I would recommend using (define-configuration ...) procedure.
>
> (There is a define-record-type* as well, but I think the consensus is that
> define-configuration* is a little easier to use.  Does better error handling
> and can help you generate documentation from the code).
>
> You can find examples of that here:
>
> https://git.savannah.gnu.org/cgit/guix.git/tree/gnu/services/mail.scm
>
> >
> > --
> > Thank you,
> > Zain Jabbar



-- 
Thank you,
Zain Jabbar


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Creating an Emacs Home Configuration Service
  2022-10-17 22:09   ` jbranso
  2022-10-17 23:12     ` Zain Jabbar
@ 2022-10-18 15:41     ` jbranso
       [not found]       ` <CAH+UbWR8xWoCK9wouhsizEzTAO3CksNpkebu5we_75yQq++yUg@mail.gmail.com>
  1 sibling, 1 reply; 13+ messages in thread
From: jbranso @ 2022-10-18 15:41 UTC (permalink / raw)
  To: Zain Jabbar; +Cc: guix-devel

October 17, 2022 7:12 PM, "Zain Jabbar" <zaijab2000@gmail.com> wrote:

> Aloha Guix Development Team,
> 
> Thank you for this email. Your advice was directed very kindly and is
> very helpful. I have tried to revise the code based on your email. I
> also checked the setting for plaintext mode in GMail; I hope this
> makes the email easier to read.
> 
> First, I define a configuration (without serialization currently).
> 
> #+BEGIN_SRC scheme
> (define file-likes? (list-of file-like?))
> 
> (define-configuration/no-serialization emacs-configuration
> (emacs-packages
> (file-likes (list (specification->package "emacs-next"))) "Files")
> (early-init
> (list '()) "Early-Init")
> (init
> (list '()) "Init"))
> #+END_SRC
> 
> Then, I define an =emacs-configuration-service= that takes in a
> configuration. This service will add packages in the =emacs-packages=
> to the profile, and append the S-Expressions in =early-init= and
> =init= to $XDG_CONFIG_HOME/emacs/early-init.el and
> $XDG_CONFIG_HOME/emacs/init.el respectively. The service has
> definition,
> 
> #+BEGIN_SRC scheme
> (define-public emacs-configuration-service
> (service-type (name (symbol-append 'emacs-configuration))
> (extensions
> (list (service-extension
> home-profile-service-type
> (lambda (config) (emacs-configuration-emacs-packages config)))
> (service-extension
> home-xdg-configuration-files-service-type
> (lambda (config)
> (list
> `("emacs/init.el" ,(scheme-file "init.el"
> (emacs-configuration-init config)
> #:splice? #:t))
> `("emacs/early-init.el" ,(scheme-file "early-init.el"
> (emacs-configuration-early-init config)
> #:splice? #:t)))))))
> (default-value (emacs-configuration))
> (description "Configures Emacs init.el")))
> #+END_SRC
> 
> This version of the service is one big service that only takes in one
> configuration file. So in order to configure bits and pieces of Emacs,
> for example evil-mode and vertico we can append emacs-configurations
> into one big configuration. I do this as follows.
> 
> #+BEGIN_SRC scheme
> (define evil-configuration
> (emacs-configuration
> (emacs-packages (list (specification->package "emacs-evil")))
> (init '((evil-mode 1)))))
> 
> (define vertico-configuration
> (emacs-configuration
> (emacs-packages (list (specification->package "emacs-vertico")))
> (init '((vertico-mode 1)))))
> 
> (define-public total-emacs-configuration
> (fold (lambda (config-1 config-2) (emacs-configuration
> (init (append (emacs-configuration-init config-1)
> (emacs-configuration-init config-2)))
> (early-init (append (emacs-configuration-early-init config-1)
> (emacs-configuration-early-init config-2)))
> (emacs-packages (append (emacs-configuration-emacs-packages config-1)
> (emacs-configuration-emacs-packages config-2)))))
> (emacs-configuration)
> (list evil-configuration vertico-configuration)))
> #+END_SRC
> 
> We can actually go crazy with this idea. The next source block is a
> generalization of the last one. Rather than declaring the list of
> configurations, we have Guile figure out all of the bound
> =emacs-configurations= in the current module and append them that way.
> 
> #+BEGIN_SRC scheme
> (define-public total-emacs-configuration
> (fold (lambda (config-1 config-2) (emacs-configuration
> (init (append (emacs-configuration-init config-1)
> (emacs-configuration-init config-2)))
> (early-init (append (emacs-configuration-early-init config-1)
> (emacs-configuration-early-init config-2)))
> (emacs-packages (append (emacs-configuration-emacs-packages config-1)
> (emacs-configuration-emacs-packages config-2)))))
> (emacs-configuration)
> 
> (filter emacs-configuration?
> (map variable-ref
> (filter variable-bound?
> (hash-map->list (lambda (x y) y) (struct-ref (current-module) 0)))))))
> #+END_SRC
> 
> What further improvements could I add to this system? The end goal
> (hopefully) is to help add another home service to Guix. I was
> inspired by David Wilson's call to action during his Guix Home talk at
> the 10 year anniversary event.
> 
> On Mon, Oct 17, 2022 at 12:09 PM <jbranso@dismail.de> wrote:
> 
>> October 17, 2022 2:38 AM, "Zain Jabbar" <zaijab2000@gmail.com> wrote:
>> 
>> Aloha Guix Development Team,
>> 
>> Running =guix home search emacs= returns nothing. I also could not find an email using =C-u M-x
>> debbugs-gnu= about an Emacs configuration service.
>> 
>> This is my first email to this mailing address. Please give me pointers on formatting and further
>> improvements.
>> 
>> I think you sent an html email. Generally you want to send plain text emails. :)
>> 
>> I have attempted to make an =emacs-home-service-type= so that it is possible to configure Emacs
>> using Guix home. This code is extremely preliminary hence I don't even think it is worth sending as
>> a patch. Also I have never worked on a multi person Git project before and do not know how to solve
>> the keyring error I get when using guix pull. I will outline what my code does and what features I
>> would like to add.
>> 
>> #+BEGIN_SRC scheme
>> (define* (emacs-configuration-service name #:key (init '()) (early-init '()) (emacs-packages '()))
>> (service-type (name (symbol-append 'emacs- name '-configuration))
>> (extensions
>> (list (service-extension
>> home-profile-service-type
>> (lambda (config) emacs-packages))
>> (service-extension
>> home-files-service-type
>> (lambda (config)
>> (list
>> `(,(string-append
>> ".config/emacs/services/" (symbol->string name) ".el")
>> ,(scheme-file (string-append (symbol->string name) ".el")
>> init #:splice? #t))
>> `(,(string-append
>> ".config/emacs/early-services/" (symbol->string name) ".el")
>> ,(scheme-file (string-append "early-" (symbol->string name) ".el")
>> early-init #:splice? #t)))))))
>> (default-value #f)
>> (description "Configures Emacs init.el")))
>> 
>> (define-public emacs-init-service-type
>> (service-type (name 'home-emacs)
>> (extensions
>> (list (service-extension
>> home-profile-service-type
>> (lambda (config) (list emacs-next)))
>> (service-extension
>> home-files-service-type
>> (lambda (config)
>> (list
>> `(".config/emacs/early-init.el"
>> ,(scheme-file
>> "early-init.el"
>> '((mapc
>> 'load (file-expand-wildcards
>> "~/.config/emacs/early-services/*.el")))
>> #:splice? #t))
>> `(".config/emacs/init.el"
>> ,(scheme-file
>> "init.el"
>> '((mapc
>> 'load (file-expand-wildcards
>> "~/.config/emacs/services/*.el")))
>> #:splice? #t)))))))
>> (default-value #f)
>> (description "Configures Emacs init.el")))
>> #+END_SRC
>> 
>> I define a general configuration service generator which takes in four things:
>> 1. The =name= of the service
>> 2. The configuration to be ran in =init.el=
>> 3. The configuration to be ran in =early-init.el=
>> 4. The packages in Guix to be added to the =home-profile=.
>> 
>> After giving the =name=, =packages=, and =config.el= files we get a new service type that we can
>> add to our home declaration. This service will then add a file in
>> =~/.config/emacs/services/emacs-{NAME}-configuration.el=. I then have another service that places
>> an =init.el= which loads everything in the service directory.
>> 
>> If we want to install and configure =evil-mode= using this =home-service= we may define the
>> following somewhere.
>> 
>> #+BEGIN_SRC scheme
>> (define-public emacs-evil-service-type
>> (emacs-configuration-service
>> 'evil #:emacs-packages (list emacs-evil)
>> #:init '((evil-mode 1))))
>> #+END_SRC
>> 
>> Within our =home-environment= we may add the service using:
>> 
>> #+BEGIN_SRC scheme
>> (home-environment
>> ;; ...Things in the home-environment...
>> (services
>> (list
>> ;; ...Other Services...
>> (service emacs-evil-service-type))))
>> #+END_SRC
>> 
>> There are some missing features I want to add.
>> 
>> 1. Have the =home-emacs-*-service-type= service-types add to the =init.el= directly rather than
>> within a folder to be loaded. I couldn't add two files with the same name to the store. So I have
>> emacs-evil.el in the store to be placed separately later rather than appending to the existing
>> init.el file.
>> 
>> 2. Have Emacs update whenever the =home-environment= is updated. Meaning, if I did not add
>> =(service emacs-evil-service-type)= in my =home-environment= then obviously =M-x evil-mode= should
>> not work. But after adding the service then I want =M-x evil-mode= to work without having to
>> restart Emacs. I do not understand the Emacs loading system on Guix well enough to know why it does
>> not work. Skipping all of the =home-service= stuff, running =guix install emacs-evil-mode= then
>> =(guix-emacs-autoload-packages)= does not let emacs know that =evil-mode= is installed. I would
>> need to close Emacs and start Emacs again for Emacs to know about =evil-mode= being installed.
>> 
>> 3. Use configurations somehow. I have completely neglected this feature in my system. I do not know
>> what would be useful there.
>> 
>> I believe that you are referring to using scheme records to configure the emacs service. :)
>> 
>> I would recommend using (define-configuration ...) procedure.
>> 
>> (There is a define-record-type* as well, but I think the consensus is that
>> define-configuration* is a little easier to use. Does better error handling
>> and can help you generate documentation from the code).
>> 
>> You can find examples of that here:
>> 
>> https://git.savannah.gnu.org/cgit/guix.git/tree/gnu/services/mail.scm
>> 
>> --
>> Thank you,
>> Zain Jabbar
> 
> --
> Thank you,
> Zain Jabbar
> 
> On Mon, Oct 17, 2022 at 12:09 PM <jbranso@dismail.de> wrote:
> 
>> October 17, 2022 2:38 AM, "Zain Jabbar" <zaijab2000@gmail.com> wrote:
>> 
>> Aloha Guix Development Team,
>> 
>> Running =guix home search emacs= returns nothing. I also could not find an email using =C-u M-x
>> debbugs-gnu= about an Emacs configuration service.
>> 
>> This is my first email to this mailing address. Please give me pointers on formatting and further
>> improvements.
>> 
>> I think you sent an html email. Generally you want to send plain text emails. :)
>> 
>> I have attempted to make an =emacs-home-service-type= so that it is possible to configure Emacs
>> using Guix home. This code is extremely preliminary hence I don't even think it is worth sending as
>> a patch. Also I have never worked on a multi person Git project before and do not know how to solve
>> the keyring error I get when using guix pull. I will outline what my code does and what features I
>> would like to add.
>> 
>> #+BEGIN_SRC scheme
>> (define* (emacs-configuration-service name #:key (init '()) (early-init '()) (emacs-packages '()))
>> (service-type (name (symbol-append 'emacs- name '-configuration))
>> (extensions
>> (list (service-extension
>> home-profile-service-type
>> (lambda (config) emacs-packages))
>> (service-extension
>> home-files-service-type
>> (lambda (config)
>> (list
>> `(,(string-append
>> ".config/emacs/services/" (symbol->string name) ".el")
>> ,(scheme-file (string-append (symbol->string name) ".el")
>> init #:splice? #t))
>> `(,(string-append
>> ".config/emacs/early-services/" (symbol->string name) ".el")
>> ,(scheme-file (string-append "early-" (symbol->string name) ".el")
>> early-init #:splice? #t)))))))
>> (default-value #f)
>> (description "Configures Emacs init.el")))
>> 
>> (define-public emacs-init-service-type
>> (service-type (name 'home-emacs)
>> (extensions
>> (list (service-extension
>> home-profile-service-type
>> (lambda (config) (list emacs-next)))
>> (service-extension
>> home-files-service-type
>> (lambda (config)
>> (list
>> `(".config/emacs/early-init.el"
>> ,(scheme-file
>> "early-init.el"
>> '((mapc
>> 'load (file-expand-wildcards
>> "~/.config/emacs/early-services/*.el")))
>> #:splice? #t))
>> `(".config/emacs/init.el"
>> ,(scheme-file
>> "init.el"
>> '((mapc
>> 'load (file-expand-wildcards
>> "~/.config/emacs/services/*.el")))
>> #:splice? #t)))))))
>> (default-value #f)
>> (description "Configures Emacs init.el")))
>> #+END_SRC
>> 
>> I define a general configuration service generator which takes in four things:
>> 1. The =name= of the service
>> 2. The configuration to be ran in =init.el=
>> 3. The configuration to be ran in =early-init.el=
>> 4. The packages in Guix to be added to the =home-profile=.
>> 
>> After giving the =name=, =packages=, and =config.el= files we get a new service type that we can
>> add to our home declaration. This service will then add a file in
>> =~/.config/emacs/services/emacs-{NAME}-configuration.el=. I then have another service that places
>> an =init.el= which loads everything in the service directory.
>> 
>> If we want to install and configure =evil-mode= using this =home-service= we may define the
>> following somewhere.
>> 
>> #+BEGIN_SRC scheme
>> (define-public emacs-evil-service-type
>> (emacs-configuration-service
>> 'evil #:emacs-packages (list emacs-evil)
>> #:init '((evil-mode 1))))
>> #+END_SRC
>> 
>> Within our =home-environment= we may add the service using:
>> 
>> #+BEGIN_SRC scheme
>> (home-environment
>> ;; ...Things in the home-environment...
>> (services
>> (list
>> ;; ...Other Services...
>> (service emacs-evil-service-type))))
>> #+END_SRC
>> 
>> There are some missing features I want to add.
>> 
>> 1. Have the =home-emacs-*-service-type= service-types add to the =init.el= directly rather than
>> within a folder to be loaded. I couldn't add two files with the same name to the store. So I have
>> emacs-evil.el in the store to be placed separately later rather than appending to the existing
>> init.el file.
>> 
>> 2. Have Emacs update whenever the =home-environment= is updated. Meaning, if I did not add
>> =(service emacs-evil-service-type)= in my =home-environment= then obviously =M-x evil-mode= should
>> not work. But after adding the service then I want =M-x evil-mode= to work without having to
>> restart Emacs. I do not understand the Emacs loading system on Guix well enough to know why it does
>> not work. Skipping all of the =home-service= stuff, running =guix install emacs-evil-mode= then
>> =(guix-emacs-autoload-packages)= does not let emacs know that =evil-mode= is installed. I would
>> need to close Emacs and start Emacs again for Emacs to know about =evil-mode= being installed.
>> 
>> 3. Use configurations somehow. I have completely neglected this feature in my system. I do not know
>> what would be useful there.
>> 
>> I believe that you are referring to using scheme records to configure the emacs service. :)
>> 
>> I would recommend using (define-configuration ...) procedure.
>> 
>> (There is a define-record-type* as well, but I think the consensus is that
>> define-configuration* is a little easier to use. Does better error handling
>> and can help you generate documentation from the code).
>> 
>> You can find examples of that here:
>> 
>> https://git.savannah.gnu.org/cgit/guix.git/tree/gnu/services/mail.scm

I'm impressed with how quickly you made your code work!  That's awesome!

Just some food for thought, if you have your emacs packages declared in your
service...would emacs still be able to look up the info documentation
for each emacs package?  Are the emacs packages added to the user's 
package store?  

Thanks,

Joshua


>> 
>> --
>> Thank you,
>> Zain Jabbar
> 
> --
> Thank you,
> Zain Jabbar


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Creating an Emacs Home Configuration Service
  2022-10-17  2:34 ` Creating an Emacs Home Configuration Service Zain Jabbar
  2022-10-17 22:09   ` jbranso
@ 2022-10-19 15:36   ` Ludovic Courtès
  2022-10-19 20:53     ` Zain Jabbar
  2022-10-20 18:35   ` Liliana Marie Prikler
  2 siblings, 1 reply; 13+ messages in thread
From: Ludovic Courtès @ 2022-10-19 15:36 UTC (permalink / raw)
  To: Zain Jabbar; +Cc: guix-devel

Hi Zain, and welcome!

Zain Jabbar <zaijab2000@gmail.com> skribis:

> Running =guix home search emacs= returns nothing. I also could not find an
> email using =C-u M-x debbugs-gnu= about an Emacs configuration service.
>
> This is my first email to this mailing address. Please give me pointers on
> formatting and further improvements.
>
> I have attempted to make an =emacs-home-service-type= so that it is
> possible to configure Emacs using Guix home. This code is extremely
> preliminary hence I don't even think it is worth sending as a patch. Also I
> have never worked on a multi person Git project before and do not know how
> to solve the keyring error I get when using guix pull. I will outline what
> my code does and what features I would like to add.

I am all for something like you describe, and the code you sent may be
good starting point!

The rde project¹ by Andrew Tropin et al. may be a good source of
inspiration.  The “features” abstraction in particular seems to be
well-suited for Emacs.  But overall it’s reasonable to start small, with
a low-level approach to combine and configure Emacs packages.

Thanks,
Ludo’.

¹ https://trop.in/rde/manual


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Creating an Emacs Home Configuration Service
       [not found]         ` <a8142b002799224845f8efdddb28e518@dismail.de>
@ 2022-10-19 18:18           ` jbranso
  2022-10-19 20:25             ` Zain Jabbar
  2022-10-19 20:56             ` jbranso
  0 siblings, 2 replies; 13+ messages in thread
From: jbranso @ 2022-10-19 18:18 UTC (permalink / raw)
  To: Zain Jabbar, guix-devel

October 18, 2022 3:42 PM, "Zain Jabbar" <zaijab2000@gmail.com> wrote:

> Here is a minimal reproducible(-ish needs change in module name)
> example configuration which installs =emacs-debbugs= (and not much
> else).

Cool I am CC-ing guix devel.

> #+BEGIN_SRC scheme
> (define-module (zaijab minimal-working-example)
> #:use-module (srfi srfi-1)
> #:use-module (ice-9 pretty-print)
> #:use-module (gnu home)
> #:use-module (gnu packages)
> #:use-module (gnu services)
> #:use-module (gnu home services)
> #:use-module (gnu services)
> #:use-module (gnu services configuration)
> #:use-module (guix gexp)
> #:use-module (guix transformations))
> 
> (define file-likes? (list-of file-like?))
> 
> (define-configuration/no-serialization emacs-configuration
> (emacs-packages
> (file-likes (list (specification->package "emacs-next"))) "Files")
> (early-init
> (list '()) "Early-Init")
> (init
> (list '()) "Init"))
> 
> (define debuggs-configuration
> (emacs-configuration
> (emacs-packages (list (specification->package "emacs-debbugs")))))
> 
> (define-public total-emacs-configuration
> (fold (lambda (config-1 config-2) (emacs-configuration
> (init (append (emacs-configuration-init config-1)
> (emacs-configuration-init config-2)))
> (early-init (append (emacs-configuration-early-init config-1)
> (emacs-configuration-early-init config-2)))
> (emacs-packages (append (emacs-configuration-emacs-packages config-1)
> (emacs-configuration-emacs-packages config-2)))))
> (emacs-configuration)
> 
> (filter emacs-configuration?
> (map variable-ref
> (filter variable-bound?
> (hash-map->list (lambda (x y) y) (struct-ref (current-module) 0)))))))
> 
> (define-public emacs-configuration-service
> (service-type (name (symbol-append 'emacs-configuration))
> (extensions
> (list (service-extension
> home-profile-service-type
> (lambda (config) (emacs-configuration-emacs-packages config)))
> (service-extension
> home-xdg-configuration-files-service-type
> (lambda (config)
> (list
> `("emacs/init.el" ,(scheme-file "init.el"
> (emacs-configuration-init config)
> #:splice? #:t))
> `("emacs/early-init.el" ,(scheme-file "early-init.el"
> (emacs-configuration-early-init config)
> #:splice? #:t)))))))
> (default-value (emacs-configuration))
> (description "Configures Emacs init.el")))
> 
> (define-public minimal-home-environment
> (home-environment
> (services (list (service emacs-configuration-service
> total-emacs-configuration)))))
> 
> minimal-home-environment
> #+END_SRC

I wonder why you do the define total-emacs-configuration...is it possible
to define an emacs-configuration something like this?

Forgive the possibly wrong syntax, I don't use guix home

(services
(service emacs-configuration-service
(emacs-configuration
(packages
(list emacs-debbugs
emacs-evil
emacs-paredit
emacs-anzu))
(init (text-file "init-file.el"
"(evil-mode 1)\n
;; other configuration stuff")))))

> I tested this using =guix home container -N
> minimal-working-example.scm=. Typing =M-x debbugs-gnu= gives a menu of
> bugs. I made sure the debbugs configuration is necessary by commenting
> it out, re-running =guix home container= and seeing that =M-x debb
> [TAB]= pulls up nothing. I think it works. Woo-hoo!

When I tested the home container via terminal foot I get a weird error:

warning: XDG_RUNTIME_DIR doesn't exists, on-first-login script
won't execute anything. You can check if xdg runtime directory exists,
XDG_RUNTIME_DIR variable is set to appropriate value and manually execute the
script by running '$HOME/.guix-home/on-first-login'-bash-5.1$ emacs
emacs: Terminal type foot is not defined.
If that is not the actual type of terminal you have,
use the Bourne shell command 'TERM=...; export TERM' (C-shell:
'setenv TERM ...') to specify the correct type. It may be necessary
to do 'unset TERMINFO' (C-shell: 'unsetenv TERMINFO') as well.

That's probably just foot being weird.

In lxterminal, emacs started fine. However, doing a M-x info RET

m Debbugs RET

I get this error in emacs:

"Creating file with prefx: No such file or directory /tmp/jka-com"

Anyway, definitely go ahead and send it to guix-patches!

> Thank you for telling me about the =,build= meta command. It looks
> very useful! I will need to figure out how to use it from =M-x
> geiser-guile=. I have built this code by doing the following:
> - open VTerm
> - guix repl
> - ,use (guix)
> - ,use (MODULE-NAME) ;; in my case this was (zaijab minimal-working-example)
> - ,build minimal-home-environment

Once you get geiser set up and clone the git repo, and compile everything...
inside the guix-src code...whatever file you are currently working on
C-c C-a opens up that file in the repl.  It's super awesome to be able to 
throw in some code evaluate it on the fly.

https://video.hardlimit.com/c/the_gnu_guy/videos

> I will be learning how to use the Git patching system soon. I will add
> more documentation when I submit the patch. I'll be sure to CC you as
> well. Thank you for your assistance.
> 
> On Tue, Oct 18, 2022 at 8:42 AM <jbranso@dismail.de> wrote:
> 
>> October 18, 2022 1:55 PM, "Zain Jabbar" <zaijab2000@gmail.com> wrote:
>> 
>> Aloha Guix Development Team,
>> 
>> Thank you for your email. I attribute my successes to the fantastic
>> documentation and my failures (as you will see in this email) to my
>> own inability to read the documentation.
>> 
>> I meant to mention, have you tried using ",build" in a geiser repl?
>> It lets you build derivations/gexps and shows you the output in
>> the store. I have found that super helpful when building my only
>> guix service (not merged yet).
>> 
>> From what I can tell, yes. Emacs does find the packages you install
>> using this mechanism and loading them behaves as though you installed
>> from a manifest. Let me know if you have a package you wish to test. I
>> can email the results.
>> 
>> emacs-debbugs. If it works, then that is awesome! Well done!
>> 
>> But I would need more guidance to answer this question fully. There
>> are some points of confusion I have relating to profiles and package
>> availability. I will try to give my best answer using the
>> documentation, source code, then a demo.
>> 
>> One thing I can say for sure is that the packages are installed using
>> the =home-profile-service-type=. According to the documentation at
>> 13.3.1 Essential Home Services the =home-profile-service-type= can be
>> "extended with a list of packages if you want to install additional
>> packages into your profile".
>> 
>> According to the source code in guix/gnu/home/services.scm
>> #+BEGIN_SRC scheme
>> ;; [In the big comment block line 76]
>> ;;; home-profile-service-type is almost the same as
>> profile-service-type, at least
>> ;;; for now.
>> .... ;; [Within the definition for home-profile-service-type (line 161)]
>> (description
>> "This is the @dfn{home profile} and can be found in
>> @file{~/.guix-home/profile}. It contains packages and
>> configuration files that the user has declared in their
>> @code{home-environment} record."))
>> #+END_SRC
>> 
>> It appears that using this configuration it installs it into the
>> =~/.guix-home/profile=. Here is where I get a bit confused, when
>> running =guix package --list-profiles= I get
>> =/home/zjabbar/.config/guix/current= and
>> =/home/zjabbar/.guix-profile=, neither of which are my home profile.
>> 
>> Here is a demo.
>> 
>> I do not have the =emacs-suneater-theme= package installed using my manifest.
>> 
>> =guix package -I suneater= returns nothing when run in the terminal.
>> 
>> After saving this configuration in the module:
>> #+BEGIN_SRC scheme
>> (define theme-configuration
>> (emacs-configuration
>> (emacs-packages (list (specification->package "emacs-suneater-theme")))
>> (init '((load-theme 'suneater t)))))
>> #+END_SRC
>> 
>> I find that Guix downloads and builds the package. After restarting
>> Emacs, it comes up with the new theme and =M-x describe-theme= finds
>> it and everything. That being said, =guix package -I suneater= *still*
>> returns nothing when run in the terminal. I suppose it's because the
>> theme was installed without using the =guix install= command
>> specifically.
>> 
>> =guix package -A suneater= does show me that suneater is available.
>> However after deleting or commenting out the configuration in that
>> source block, Emacs does not load the theme and Emacs cannot find the
>> theme using =M-x describe-theme=. But =guix package -A suneater= still
>> shows me that suneater is available. So it was removed according to
>> Emacs but not to guix. I am likely not looking at the right =guix
>> package= options.
>> 
>> It sounds like you have created the home-emacs service is a way that works.
>> I think your next move would be submit it guix-patches@gnu.org.
>> Feel free to CC me in the email.
>> 
>> https://git-send-email.io
>> 
>> Thanks,
>> 
>> Joshua
> 
> --
> Thank you,
> Zain Jabbar
> 
> On Tue, Oct 18, 2022 at 8:42 AM <jbranso@dismail.de> wrote:
> 
>> October 18, 2022 1:55 PM, "Zain Jabbar" <zaijab2000@gmail.com> wrote:
>> 
>> Aloha Guix Development Team,
>> 
>> Thank you for your email. I attribute my successes to the fantastic
>> documentation and my failures (as you will see in this email) to my
>> own inability to read the documentation.
>> 
>> I meant to mention, have you tried using ",build" in a geiser repl?
>> It lets you build derivations/gexps and shows you the output in
>> the store. I have found that super helpful when building my only
>> guix service (not merged yet).
>> 
>> From what I can tell, yes. Emacs does find the packages you install
>> using this mechanism and loading them behaves as though you installed
>> from a manifest. Let me know if you have a package you wish to test. I
>> can email the results.
>> 
>> emacs-debbugs. If it works, then that is awesome! Well done!
>> 
>> But I would need more guidance to answer this question fully. There
>> are some points of confusion I have relating to profiles and package
>> availability. I will try to give my best answer using the
>> documentation, source code, then a demo.
>> 
>> One thing I can say for sure is that the packages are installed using
>> the =home-profile-service-type=. According to the documentation at
>> 13.3.1 Essential Home Services the =home-profile-service-type= can be
>> "extended with a list of packages if you want to install additional
>> packages into your profile".
>> 
>> According to the source code in guix/gnu/home/services.scm
>> #+BEGIN_SRC scheme
>> ;; [In the big comment block line 76]
>> ;;; home-profile-service-type is almost the same as
>> profile-service-type, at least
>> ;;; for now.
>> .... ;; [Within the definition for home-profile-service-type (line 161)]
>> (description
>> "This is the @dfn{home profile} and can be found in
>> @file{~/.guix-home/profile}. It contains packages and
>> configuration files that the user has declared in their
>> @code{home-environment} record."))
>> #+END_SRC
>> 
>> It appears that using this configuration it installs it into the
>> =~/.guix-home/profile=. Here is where I get a bit confused, when
>> running =guix package --list-profiles= I get
>> =/home/zjabbar/.config/guix/current= and
>> =/home/zjabbar/.guix-profile=, neither of which are my home profile.
>> 
>> Here is a demo.
>> 
>> I do not have the =emacs-suneater-theme= package installed using my manifest.
>> 
>> =guix package -I suneater= returns nothing when run in the terminal.
>> 
>> After saving this configuration in the module:
>> #+BEGIN_SRC scheme
>> (define theme-configuration
>> (emacs-configuration
>> (emacs-packages (list (specification->package "emacs-suneater-theme")))
>> (init '((load-theme 'suneater t)))))
>> #+END_SRC
>> 
>> I find that Guix downloads and builds the package. After restarting
>> Emacs, it comes up with the new theme and =M-x describe-theme= finds
>> it and everything. That being said, =guix package -I suneater= *still*
>> returns nothing when run in the terminal. I suppose it's because the
>> theme was installed without using the =guix install= command
>> specifically.
>> 
>> =guix package -A suneater= does show me that suneater is available.
>> However after deleting or commenting out the configuration in that
>> source block, Emacs does not load the theme and Emacs cannot find the
>> theme using =M-x describe-theme=. But =guix package -A suneater= still
>> shows me that suneater is available. So it was removed according to
>> Emacs but not to guix. I am likely not looking at the right =guix
>> package= options.
>> 
>> It sounds like you have created the home-emacs service is a way that works.
>> I think your next move would be submit it guix-patches@gnu.org.
>> Feel free to CC me in the email.
>> 
>> https://git-send-email.io
>> 
>> Thanks,
>> 
>> Joshua
> 
> --
> Thank you,
> Zain Jabbar


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Creating an Emacs Home Configuration Service
  2022-10-19 18:18           ` jbranso
@ 2022-10-19 20:25             ` Zain Jabbar
  2022-10-19 20:56             ` jbranso
  1 sibling, 0 replies; 13+ messages in thread
From: Zain Jabbar @ 2022-10-19 20:25 UTC (permalink / raw)
  To: jbranso; +Cc: guix-devel

Aloha All,

Thank you for your insightful messages. Sorry my code did not work as
smoothly as I would have liked. I have a =home-environment= definition
that hopefully works for you. You can put everything into one
configuration as you described. I do that in the following source
block. For some reason I liked the idea of separate definitions of
each package, so that Guile and Guix Home kind of acts like a
=use-package= declaration. Though that was needless abstraction on my
end.

#+BEGIN_SRC scheme
(use-modules (srfi srfi-1)
     (ice-9 pretty-print)
     (gnu home)
     (gnu packages)
     (gnu services)
     (gnu home services)
     (gnu services configuration)
     (guix gexp)
     (guix transformations))

(define file-likes? (list-of file-like?))

(define-configuration/no-serialization emacs-configuration
  (emacs-packages
   (file-likes (list (specification->package "emacs-next"))) "Files")
  (early-init
   (list '()) "Early-Init")
  (init
   (list '()) "Init"))

(define-public emacs-configuration-service
  (service-type (name (symbol-append 'emacs-configuration))
(extensions
(list (service-extension
home-profile-service-type
(lambda (config) (emacs-configuration-emacs-packages config)))
       (service-extension
home-xdg-configuration-files-service-type
(lambda (config)
  (list
   `("emacs/init.el" ,(scheme-file "init.el"
  (emacs-configuration-init config)
  #:splice? #:t))
   `("emacs/early-init.el" ,(scheme-file "early-init.el"
  (emacs-configuration-early-init config)
  #:splice? #:t)))))))
(default-value (emacs-configuration))
(description "Configures Emacs init.el")))

(define-public minimal-home-environment
  (home-environment
   (services
    (list
     (service emacs-configuration-service
      (emacs-configuration
       (emacs-packages
(list
(specification->package "bash")
(specification->package "emacs-next")
(specification->package "emacs-debbugs")
(specification->package "emacs-evil")
(specification->package "emacs-paredit")
(specification->package "emacs-anzu")))
       (init '((evil-mode 1)
       ;; Please add more config here
       ;; Begining of emacs init configuration after evil-mode 1

       ;; End emacs init configuration
       ))
       (early-init '((setq warning-suppress-log-types '((comp) (comp)))
     (setq warning-suppress-types '((comp) (comp))))))))))) ; A
serious stack of pringles here

minimal-home-environment
#+END_SRC

I saved this file to =minimal-working-example.scm= and ran a container using
=guix home -N --share=/tmp container ./minimal-working-example.scm=.
This should spawn a shell in which you can run =emacs= (as terminal).
Furthermore we can also run the info help command and get to the
debbugs page.

The =init= and =early-init= configuration options take in
S-Expressions not files. Under the hood the service uses =scheme-file=
which takes in an expression. I am open to suggestions for other file
mechanisms, like if, for example, G-Expressions are more natural here.
I found that I did not know how to naturally append G-Expressions
together and that the S-Expressions can "bleed" into the config using
backquotes. So I chose just sticking in a list of expressions for
Emacs. Something Andrew Tropin taught me, if you are working in a
=*.scm= file and you want to evaluate elisp, use =M-x eval-region= or
=M-x edit-indirect-region= (with the usual stipulation that if you do
this very often we can bind it to a key).

If my interpretation of 13.1 Declaring the Home Environment is
correct, we should expect an error associated with XDG_RUNTIME_DIR as
the necessary variables will be set via the Operating-System
declaration. The next error I believe is emacs wanting to make a file
where the home container does not have read or write permissions. My
=guix home= declaration with the =share= parameter should hopefully
help with this error. Oddly enough if we do not specify the
installation of =bash=, Emacs says it cannot uncompress the info
manuals because there is no =sh=. That is why I included =bash= into
the emacs packages list. I do think a lot of these "solutions" will be
unncessecary if users were to use =guix home reconfigure= rather than
user the container. Though it's nice to debug them there.

On Wed, Oct 19, 2022 at 8:19 AM <jbranso@dismail.de> wrote:
>
> October 18, 2022 3:42 PM, "Zain Jabbar" <zaijab2000@gmail.com> wrote:
>
> > Here is a minimal reproducible(-ish needs change in module name)
> > example configuration which installs =emacs-debbugs= (and not much
> > else).
>
> Cool I am CC-ing guix devel.
>
> > #+BEGIN_SRC scheme
> > (define-module (zaijab minimal-working-example)
> > #:use-module (srfi srfi-1)
> > #:use-module (ice-9 pretty-print)
> > #:use-module (gnu home)
> > #:use-module (gnu packages)
> > #:use-module (gnu services)
> > #:use-module (gnu home services)
> > #:use-module (gnu services)
> > #:use-module (gnu services configuration)
> > #:use-module (guix gexp)
> > #:use-module (guix transformations))
> >
> > (define file-likes? (list-of file-like?))
> >
> > (define-configuration/no-serialization emacs-configuration
> > (emacs-packages
> > (file-likes (list (specification->package "emacs-next"))) "Files")
> > (early-init
> > (list '()) "Early-Init")
> > (init
> > (list '()) "Init"))
> >
> > (define debuggs-configuration
> > (emacs-configuration
> > (emacs-packages (list (specification->package "emacs-debbugs")))))
> >
> > (define-public total-emacs-configuration
> > (fold (lambda (config-1 config-2) (emacs-configuration
> > (init (append (emacs-configuration-init config-1)
> > (emacs-configuration-init config-2)))
> > (early-init (append (emacs-configuration-early-init config-1)
> > (emacs-configuration-early-init config-2)))
> > (emacs-packages (append (emacs-configuration-emacs-packages config-1)
> > (emacs-configuration-emacs-packages config-2)))))
> > (emacs-configuration)
> >
> > (filter emacs-configuration?
> > (map variable-ref
> > (filter variable-bound?
> > (hash-map->list (lambda (x y) y) (struct-ref (current-module) 0)))))))
> >
> > (define-public emacs-configuration-service
> > (service-type (name (symbol-append 'emacs-configuration))
> > (extensions
> > (list (service-extension
> > home-profile-service-type
> > (lambda (config) (emacs-configuration-emacs-packages config)))
> > (service-extension
> > home-xdg-configuration-files-service-type
> > (lambda (config)
> > (list
> > `("emacs/init.el" ,(scheme-file "init.el"
> > (emacs-configuration-init config)
> > #:splice? #:t))
> > `("emacs/early-init.el" ,(scheme-file "early-init.el"
> > (emacs-configuration-early-init config)
> > #:splice? #:t)))))))
> > (default-value (emacs-configuration))
> > (description "Configures Emacs init.el")))
> >
> > (define-public minimal-home-environment
> > (home-environment
> > (services (list (service emacs-configuration-service
> > total-emacs-configuration)))))
> >
> > minimal-home-environment
> > #+END_SRC
>
> I wonder why you do the define total-emacs-configuration...is it possible
> to define an emacs-configuration something like this?
>
> Forgive the possibly wrong syntax, I don't use guix home
>
> (services
> (service emacs-configuration-service
> (emacs-configuration
> (packages
> (list emacs-debbugs
> emacs-evil
> emacs-paredit
> emacs-anzu))
> (init (text-file "init-file.el"
> "(evil-mode 1)\n
> ;; other configuration stuff")))))
>
> > I tested this using =guix home container -N
> > minimal-working-example.scm=. Typing =M-x debbugs-gnu= gives a menu of
> > bugs. I made sure the debbugs configuration is necessary by commenting
> > it out, re-running =guix home container= and seeing that =M-x debb
> > [TAB]= pulls up nothing. I think it works. Woo-hoo!
>
> When I tested the home container via terminal foot I get a weird error:
>
> warning: XDG_RUNTIME_DIR doesn't exists, on-first-login script
> won't execute anything. You can check if xdg runtime directory exists,
> XDG_RUNTIME_DIR variable is set to appropriate value and manually execute the
> script by running '$HOME/.guix-home/on-first-login'-bash-5.1$ emacs
> emacs: Terminal type foot is not defined.
> If that is not the actual type of terminal you have,
> use the Bourne shell command 'TERM=...; export TERM' (C-shell:
> 'setenv TERM ...') to specify the correct type. It may be necessary
> to do 'unset TERMINFO' (C-shell: 'unsetenv TERMINFO') as well.
>
> That's probably just foot being weird.
>
> In lxterminal, emacs started fine. However, doing a M-x info RET
>
> m Debbugs RET
>
> I get this error in emacs:
>
> "Creating file with prefx: No such file or directory /tmp/jka-com"
>
> Anyway, definitely go ahead and send it to guix-patches!
>
> > Thank you for telling me about the =,build= meta command. It looks
> > very useful! I will need to figure out how to use it from =M-x
> > geiser-guile=. I have built this code by doing the following:
> > - open VTerm
> > - guix repl
> > - ,use (guix)
> > - ,use (MODULE-NAME) ;; in my case this was (zaijab minimal-working-example)
> > - ,build minimal-home-environment
>
> Once you get geiser set up and clone the git repo, and compile everything...
> inside the guix-src code...whatever file you are currently working on
> C-c C-a opens up that file in the repl.  It's super awesome to be able to
> throw in some code evaluate it on the fly.
>
> https://video.hardlimit.com/c/the_gnu_guy/videos
>
> > I will be learning how to use the Git patching system soon. I will add
> > more documentation when I submit the patch. I'll be sure to CC you as
> > well. Thank you for your assistance.
> >
> > On Tue, Oct 18, 2022 at 8:42 AM <jbranso@dismail.de> wrote:
> >
> >> October 18, 2022 1:55 PM, "Zain Jabbar" <zaijab2000@gmail.com> wrote:
> >>
> >> Aloha Guix Development Team,
> >>
> >> Thank you for your email. I attribute my successes to the fantastic
> >> documentation and my failures (as you will see in this email) to my
> >> own inability to read the documentation.
> >>
> >> I meant to mention, have you tried using ",build" in a geiser repl?
> >> It lets you build derivations/gexps and shows you the output in
> >> the store. I have found that super helpful when building my only
> >> guix service (not merged yet).
> >>
> >> From what I can tell, yes. Emacs does find the packages you install
> >> using this mechanism and loading them behaves as though you installed
> >> from a manifest. Let me know if you have a package you wish to test. I
> >> can email the results.
> >>
> >> emacs-debbugs. If it works, then that is awesome! Well done!
> >>
> >> But I would need more guidance to answer this question fully. There
> >> are some points of confusion I have relating to profiles and package
> >> availability. I will try to give my best answer using the
> >> documentation, source code, then a demo.
> >>
> >> One thing I can say for sure is that the packages are installed using
> >> the =home-profile-service-type=. According to the documentation at
> >> 13.3.1 Essential Home Services the =home-profile-service-type= can be
> >> "extended with a list of packages if you want to install additional
> >> packages into your profile".
> >>
> >> According to the source code in guix/gnu/home/services.scm
> >> #+BEGIN_SRC scheme
> >> ;; [In the big comment block line 76]
> >> ;;; home-profile-service-type is almost the same as
> >> profile-service-type, at least
> >> ;;; for now.
> >> .... ;; [Within the definition for home-profile-service-type (line 161)]
> >> (description
> >> "This is the @dfn{home profile} and can be found in
> >> @file{~/.guix-home/profile}. It contains packages and
> >> configuration files that the user has declared in their
> >> @code{home-environment} record."))
> >> #+END_SRC
> >>
> >> It appears that using this configuration it installs it into the
> >> =~/.guix-home/profile=. Here is where I get a bit confused, when
> >> running =guix package --list-profiles= I get
> >> =/home/zjabbar/.config/guix/current= and
> >> =/home/zjabbar/.guix-profile=, neither of which are my home profile.
> >>
> >> Here is a demo.
> >>
> >> I do not have the =emacs-suneater-theme= package installed using my manifest.
> >>
> >> =guix package -I suneater= returns nothing when run in the terminal.
> >>
> >> After saving this configuration in the module:
> >> #+BEGIN_SRC scheme
> >> (define theme-configuration
> >> (emacs-configuration
> >> (emacs-packages (list (specification->package "emacs-suneater-theme")))
> >> (init '((load-theme 'suneater t)))))
> >> #+END_SRC
> >>
> >> I find that Guix downloads and builds the package. After restarting
> >> Emacs, it comes up with the new theme and =M-x describe-theme= finds
> >> it and everything. That being said, =guix package -I suneater= *still*
> >> returns nothing when run in the terminal. I suppose it's because the
> >> theme was installed without using the =guix install= command
> >> specifically.
> >>
> >> =guix package -A suneater= does show me that suneater is available.
> >> However after deleting or commenting out the configuration in that
> >> source block, Emacs does not load the theme and Emacs cannot find the
> >> theme using =M-x describe-theme=. But =guix package -A suneater= still
> >> shows me that suneater is available. So it was removed according to
> >> Emacs but not to guix. I am likely not looking at the right =guix
> >> package= options.
> >>
> >> It sounds like you have created the home-emacs service is a way that works.
> >> I think your next move would be submit it guix-patches@gnu.org.
> >> Feel free to CC me in the email.
> >>
> >> https://git-send-email.io
> >>
> >> Thanks,
> >>
> >> Joshua
> >
> > --
> > Thank you,
> > Zain Jabbar
> >
> > On Tue, Oct 18, 2022 at 8:42 AM <jbranso@dismail.de> wrote:
> >
> >> October 18, 2022 1:55 PM, "Zain Jabbar" <zaijab2000@gmail.com> wrote:
> >>
> >> Aloha Guix Development Team,
> >>
> >> Thank you for your email. I attribute my successes to the fantastic
> >> documentation and my failures (as you will see in this email) to my
> >> own inability to read the documentation.
> >>
> >> I meant to mention, have you tried using ",build" in a geiser repl?
> >> It lets you build derivations/gexps and shows you the output in
> >> the store. I have found that super helpful when building my only
> >> guix service (not merged yet).
> >>
> >> From what I can tell, yes. Emacs does find the packages you install
> >> using this mechanism and loading them behaves as though you installed
> >> from a manifest. Let me know if you have a package you wish to test. I
> >> can email the results.
> >>
> >> emacs-debbugs. If it works, then that is awesome! Well done!
> >>
> >> But I would need more guidance to answer this question fully. There
> >> are some points of confusion I have relating to profiles and package
> >> availability. I will try to give my best answer using the
> >> documentation, source code, then a demo.
> >>
> >> One thing I can say for sure is that the packages are installed using
> >> the =home-profile-service-type=. According to the documentation at
> >> 13.3.1 Essential Home Services the =home-profile-service-type= can be
> >> "extended with a list of packages if you want to install additional
> >> packages into your profile".
> >>
> >> According to the source code in guix/gnu/home/services.scm
> >> #+BEGIN_SRC scheme
> >> ;; [In the big comment block line 76]
> >> ;;; home-profile-service-type is almost the same as
> >> profile-service-type, at least
> >> ;;; for now.
> >> .... ;; [Within the definition for home-profile-service-type (line 161)]
> >> (description
> >> "This is the @dfn{home profile} and can be found in
> >> @file{~/.guix-home/profile}. It contains packages and
> >> configuration files that the user has declared in their
> >> @code{home-environment} record."))
> >> #+END_SRC
> >>
> >> It appears that using this configuration it installs it into the
> >> =~/.guix-home/profile=. Here is where I get a bit confused, when
> >> running =guix package --list-profiles= I get
> >> =/home/zjabbar/.config/guix/current= and
> >> =/home/zjabbar/.guix-profile=, neither of which are my home profile.
> >>
> >> Here is a demo.
> >>
> >> I do not have the =emacs-suneater-theme= package installed using my manifest.
> >>
> >> =guix package -I suneater= returns nothing when run in the terminal.
> >>
> >> After saving this configuration in the module:
> >> #+BEGIN_SRC scheme
> >> (define theme-configuration
> >> (emacs-configuration
> >> (emacs-packages (list (specification->package "emacs-suneater-theme")))
> >> (init '((load-theme 'suneater t)))))
> >> #+END_SRC
> >>
> >> I find that Guix downloads and builds the package. After restarting
> >> Emacs, it comes up with the new theme and =M-x describe-theme= finds
> >> it and everything. That being said, =guix package -I suneater= *still*
> >> returns nothing when run in the terminal. I suppose it's because the
> >> theme was installed without using the =guix install= command
> >> specifically.
> >>
> >> =guix package -A suneater= does show me that suneater is available.
> >> However after deleting or commenting out the configuration in that
> >> source block, Emacs does not load the theme and Emacs cannot find the
> >> theme using =M-x describe-theme=. But =guix package -A suneater= still
> >> shows me that suneater is available. So it was removed according to
> >> Emacs but not to guix. I am likely not looking at the right =guix
> >> package= options.
> >>
> >> It sounds like you have created the home-emacs service is a way that works.
> >> I think your next move would be submit it guix-patches@gnu.org.
> >> Feel free to CC me in the email.
> >>
> >> https://git-send-email.io
> >>
> >> Thanks,
> >>
> >> Joshua
> >
> > --
> > Thank you,
> > Zain Jabbar



-- 
Thank you,
Zain Jabbar


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Creating an Emacs Home Configuration Service
  2022-10-19 15:36   ` Ludovic Courtès
@ 2022-10-19 20:53     ` Zain Jabbar
  2022-10-20  7:22       ` Andrew Tropin
  2022-10-20 13:17       ` Ludovic Courtès
  0 siblings, 2 replies; 13+ messages in thread
From: Zain Jabbar @ 2022-10-19 20:53 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guix-devel

Aloha All,

Super awesome to hear from you! I'm quite star stuck.

Thank you for showcasing Andrew Tropin's rde project. I believe the
=features= abstraction have potential and make more intuitive sense
for the design of configurable programs. There is a lot for me to
learn from this design choice.

As it stands, =features= are not in Guix proper, are there plans to
merge them? How will they end up relating to the existing home
services feature set?

On Wed, Oct 19, 2022 at 5:36 AM Ludovic Courtès <ludo@gnu.org> wrote:
>
> Hi Zain, and welcome!
>
> Zain Jabbar <zaijab2000@gmail.com> skribis:
>
> > Running =guix home search emacs= returns nothing. I also could not find an
> > email using =C-u M-x debbugs-gnu= about an Emacs configuration service.
> >
> > This is my first email to this mailing address. Please give me pointers on
> > formatting and further improvements.
> >
> > I have attempted to make an =emacs-home-service-type= so that it is
> > possible to configure Emacs using Guix home. This code is extremely
> > preliminary hence I don't even think it is worth sending as a patch. Also I
> > have never worked on a multi person Git project before and do not know how
> > to solve the keyring error I get when using guix pull. I will outline what
> > my code does and what features I would like to add.
>
> I am all for something like you describe, and the code you sent may be
> good starting point!
>
> The rde project¹ by Andrew Tropin et al. may be a good source of
> inspiration.  The “features” abstraction in particular seems to be
> well-suited for Emacs.  But overall it’s reasonable to start small, with
> a low-level approach to combine and configure Emacs packages.
>
> Thanks,
> Ludo’.
>
> ¹ https://trop.in/rde/manual



-- 
Thank you,
Zain Jabbar


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Creating an Emacs Home Configuration Service
  2022-10-19 18:18           ` jbranso
  2022-10-19 20:25             ` Zain Jabbar
@ 2022-10-19 20:56             ` jbranso
  2022-10-19 21:09               ` Zain Jabbar
  1 sibling, 1 reply; 13+ messages in thread
From: jbranso @ 2022-10-19 20:56 UTC (permalink / raw)
  To: Zain Jabbar; +Cc: guix-devel

October 19, 2022 4:25 PM, "Zain Jabbar" <zaijab2000@gmail.com> wrote:

> Aloha All,
> 
> Thank you for your insightful messages. Sorry my code did not work as
> smoothly as I would have liked. I have a =home-environment= definition
> that hopefully works for you. You can put everything into one
> configuration as you described. I do that in the following source
> block. For some reason I liked the idea of separate definitions of
> each package, so that Guile and Guix Home kind of acts like a
> =use-package= declaration. Though that was needless abstraction on my
> end.

I do not know if it is a needless abstraction.  I am just bouncing ideas
around with you.  :)

> 
> #+BEGIN_SRC scheme
> (use-modules (srfi srfi-1)
> (ice-9 pretty-print)
> (gnu home)
> (gnu packages)
> (gnu services)
> (gnu home services)
> (gnu services configuration)
> (guix gexp)
> (guix transformations))
> 
> (define file-likes? (list-of file-like?))
> 
> (define-configuration/no-serialization emacs-configuration
> (emacs-packages
> (file-likes (list (specification->package "emacs-next"))) "Files")
> (early-init
> (list '()) "Early-Init")
> (init
> (list '()) "Init"))
> 
> (define-public emacs-configuration-service
> (service-type (name (symbol-append 'emacs-configuration))
> (extensions
> (list (service-extension
> home-profile-service-type
> (lambda (config) (emacs-configuration-emacs-packages config)))
> (service-extension
> home-xdg-configuration-files-service-type
> (lambda (config)
> (list
> `("emacs/init.el" ,(scheme-file "init.el"
> (emacs-configuration-init config)
> #:splice? #:t))
> `("emacs/early-init.el" ,(scheme-file "early-init.el"
> (emacs-configuration-early-init config)
> #:splice? #:t)))))))
> (default-value (emacs-configuration))
> (description "Configures Emacs init.el")))
> 
> (define-public minimal-home-environment
> (home-environment
> (services
> (list
> (service emacs-configuration-service
> (emacs-configuration
> (emacs-packages
> (list
> (specification->package "bash")
> (specification->package "emacs-next")
> (specification->package "emacs-debbugs")
> (specification->package "emacs-evil")
> (specification->package "emacs-paredit")
> (specification->package "emacs-anzu")))
> (init '((evil-mode 1)
> ;; Please add more config here
> ;; Begining of emacs init configuration after evil-mode 1
> 
> ;; End emacs init configuration
> ))
> (early-init '((setq warning-suppress-log-types '((comp) (comp)))
> (setq warning-suppress-types '((comp) (comp))))))))))) ; A
> serious stack of pringles here
> 
> minimal-home-environment
> #+END_SRC
> 
> I saved this file to =minimal-working-example.scm= and ran a container using
> =guix home -N --share=/tmp container ./minimal-working-example.scm=.
> This should spawn a shell in which you can run =emacs= (as terminal).
> Furthermore we can also run the info help command and get to the
> debbugs page.
> 
> The =init= and =early-init= configuration options take in
> S-Expressions not files. Under the hood the service uses =scheme-file=
> which takes in an expression. I am open to suggestions for other file
> mechanisms, like if, for example, G-Expressions are more natural here.
> I found that I did not know how to naturally append G-Expressions
> together and that the S-Expressions can "bleed" into the config using
> backquotes. So I chose just sticking in a list of expressions for
> Emacs. Something Andrew Tropin taught me, if you are working in a
> =*.scm= file and you want to evaluate elisp, use =M-x eval-region= or
> =M-x edit-indirect-region= (with the usual stipulation that if you do
> this very often we can bind it to a key).

I would say when you submit your service to guix-devel others will give
you some options too.  I like the idea of S-expressions though.

 
> If my interpretation of 13.1 Declaring the Home Environment is
> correct, we should expect an error associated with XDG_RUNTIME_DIR as
> the necessary variables will be set via the Operating-System
> declaration. The next error I believe is emacs wanting to make a file
> where the home container does not have read or write permissions. My
> =guix home= declaration with the =share= parameter should hopefully
> help with this error. Oddly enough if we do not specify the
> installation of =bash=, Emacs says it cannot uncompress the info
> manuals because there is no =sh=. That is why I included =bash= into
> the emacs packages list. I do think a lot of these "solutions" will be
> unncessecary if users were to use =guix home reconfigure= rather than
> user the container. Though it's nice to debug them there.

Thanks for the explanation!


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Creating an Emacs Home Configuration Service
  2022-10-19 20:56             ` jbranso
@ 2022-10-19 21:09               ` Zain Jabbar
  0 siblings, 0 replies; 13+ messages in thread
From: Zain Jabbar @ 2022-10-19 21:09 UTC (permalink / raw)
  To: jbranso; +Cc: guix-devel

Aloha All,

Thank you for your input! It's all been very constructive. I will do
my best on that patch.

On Wed, Oct 19, 2022 at 10:56 AM <jbranso@dismail.de> wrote:
>
> October 19, 2022 4:25 PM, "Zain Jabbar" <zaijab2000@gmail.com> wrote:
>
> > Aloha All,
> >
> > Thank you for your insightful messages. Sorry my code did not work as
> > smoothly as I would have liked. I have a =home-environment= definition
> > that hopefully works for you. You can put everything into one
> > configuration as you described. I do that in the following source
> > block. For some reason I liked the idea of separate definitions of
> > each package, so that Guile and Guix Home kind of acts like a
> > =use-package= declaration. Though that was needless abstraction on my
> > end.
>
> I do not know if it is a needless abstraction.  I am just bouncing ideas
> around with you.  :)
>
> >
> > #+BEGIN_SRC scheme
> > (use-modules (srfi srfi-1)
> > (ice-9 pretty-print)
> > (gnu home)
> > (gnu packages)
> > (gnu services)
> > (gnu home services)
> > (gnu services configuration)
> > (guix gexp)
> > (guix transformations))
> >
> > (define file-likes? (list-of file-like?))
> >
> > (define-configuration/no-serialization emacs-configuration
> > (emacs-packages
> > (file-likes (list (specification->package "emacs-next"))) "Files")
> > (early-init
> > (list '()) "Early-Init")
> > (init
> > (list '()) "Init"))
> >
> > (define-public emacs-configuration-service
> > (service-type (name (symbol-append 'emacs-configuration))
> > (extensions
> > (list (service-extension
> > home-profile-service-type
> > (lambda (config) (emacs-configuration-emacs-packages config)))
> > (service-extension
> > home-xdg-configuration-files-service-type
> > (lambda (config)
> > (list
> > `("emacs/init.el" ,(scheme-file "init.el"
> > (emacs-configuration-init config)
> > #:splice? #:t))
> > `("emacs/early-init.el" ,(scheme-file "early-init.el"
> > (emacs-configuration-early-init config)
> > #:splice? #:t)))))))
> > (default-value (emacs-configuration))
> > (description "Configures Emacs init.el")))
> >
> > (define-public minimal-home-environment
> > (home-environment
> > (services
> > (list
> > (service emacs-configuration-service
> > (emacs-configuration
> > (emacs-packages
> > (list
> > (specification->package "bash")
> > (specification->package "emacs-next")
> > (specification->package "emacs-debbugs")
> > (specification->package "emacs-evil")
> > (specification->package "emacs-paredit")
> > (specification->package "emacs-anzu")))
> > (init '((evil-mode 1)
> > ;; Please add more config here
> > ;; Begining of emacs init configuration after evil-mode 1
> >
> > ;; End emacs init configuration
> > ))
> > (early-init '((setq warning-suppress-log-types '((comp) (comp)))
> > (setq warning-suppress-types '((comp) (comp))))))))))) ; A
> > serious stack of pringles here
> >
> > minimal-home-environment
> > #+END_SRC
> >
> > I saved this file to =minimal-working-example.scm= and ran a container using
> > =guix home -N --share=/tmp container ./minimal-working-example.scm=.
> > This should spawn a shell in which you can run =emacs= (as terminal).
> > Furthermore we can also run the info help command and get to the
> > debbugs page.
> >
> > The =init= and =early-init= configuration options take in
> > S-Expressions not files. Under the hood the service uses =scheme-file=
> > which takes in an expression. I am open to suggestions for other file
> > mechanisms, like if, for example, G-Expressions are more natural here.
> > I found that I did not know how to naturally append G-Expressions
> > together and that the S-Expressions can "bleed" into the config using
> > backquotes. So I chose just sticking in a list of expressions for
> > Emacs. Something Andrew Tropin taught me, if you are working in a
> > =*.scm= file and you want to evaluate elisp, use =M-x eval-region= or
> > =M-x edit-indirect-region= (with the usual stipulation that if you do
> > this very often we can bind it to a key).
>
> I would say when you submit your service to guix-devel others will give
> you some options too.  I like the idea of S-expressions though.
>
>
> > If my interpretation of 13.1 Declaring the Home Environment is
> > correct, we should expect an error associated with XDG_RUNTIME_DIR as
> > the necessary variables will be set via the Operating-System
> > declaration. The next error I believe is emacs wanting to make a file
> > where the home container does not have read or write permissions. My
> > =guix home= declaration with the =share= parameter should hopefully
> > help with this error. Oddly enough if we do not specify the
> > installation of =bash=, Emacs says it cannot uncompress the info
> > manuals because there is no =sh=. That is why I included =bash= into
> > the emacs packages list. I do think a lot of these "solutions" will be
> > unncessecary if users were to use =guix home reconfigure= rather than
> > user the container. Though it's nice to debug them there.
>
> Thanks for the explanation!



-- 
Thank you,
Zain Jabbar


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Creating an Emacs Home Configuration Service
  2022-10-19 20:53     ` Zain Jabbar
@ 2022-10-20  7:22       ` Andrew Tropin
  2022-10-20 13:17       ` Ludovic Courtès
  1 sibling, 0 replies; 13+ messages in thread
From: Andrew Tropin @ 2022-10-20  7:22 UTC (permalink / raw)
  To: Zain Jabbar, Ludovic Courtès; +Cc: guix-devel

[-- Attachment #1: Type: text/plain, Size: 3591 bytes --]

On 2022-10-19 10:53, Zain Jabbar wrote:

> Aloha All,
>
> Super awesome to hear from you! I'm quite star stuck.
>
> Thank you for showcasing Andrew Tropin's rde project. I believe the
> =features= abstraction have potential and make more intuitive sense
> for the design of configurable programs. There is a lot for me to
> learn from this design choice.
>
> As it stands, =features= are not in Guix proper, are there plans to
> merge them?

There was no plan to merge this mechanism to Guix proper and I think
it's actually good to maintain this as a separate project/guix channel,
however it is discussable.  Features itself are quite opinionated and
doesn't fit general-purpose nature of the Guix IMO, so I don't think we
(Guix devs) want to merge them.

> How will they end up relating to the existing home services feature
> set?

rde features are basically wrappers around home and system services,
which allows to share values among those services, also it allows to
implement polymorphic behavior.

You can trace origins somewhere in rde-devel mailing list:
https://lists.sr.ht/~abcdw/rde-devel/%3C87sg56g97i.fsf%40trop.in%3E

Because rde features are a user-facing interface, and services mechanism
is slightly hidden underneath, rde's home and system services are less
suitable for end-user, but more flexible.  We (rde devs) usually don't
use records, which help to define rigid config structure, provide
autocompletion, field existence and type checks, and other benifits, but
provide sxml or other sexp based representation of underlying
configuration formats.

BTW, there is an emacs-home-service-type in rde:
https://git.sr.ht/~abcdw/rde/tree/59a2c1ef615aac7c5dac08660bd00ea5873e77b7/rde/home/services/emacs.scm#L20

and you can find various usage examples in people's configuration or in
rde/feature/emacs* modules.
https://git.sr.ht/~krevedkokun/dotfiles/tree/master/item/config/home/yggdrasil/emacs.scm
https://git.sr.ht/~akagi/guixrc/tree/master/item/magi/home/emacs.scm
https://git.sr.ht/~abcdw/rde/tree/master/item/rde/features/emacs.scm
https://git.sr.ht/~abcdw/rde/tree/master/item/rde/features/emacs-xyz.scm

>
> On Wed, Oct 19, 2022 at 5:36 AM Ludovic Courtès <ludo@gnu.org> wrote:
>>
>> Hi Zain, and welcome!
>>
>> Zain Jabbar <zaijab2000@gmail.com> skribis:
>>
>> > Running =guix home search emacs= returns nothing. I also could not find an
>> > email using =C-u M-x debbugs-gnu= about an Emacs configuration service.
>> >
>> > This is my first email to this mailing address. Please give me pointers on
>> > formatting and further improvements.
>> >
>> > I have attempted to make an =emacs-home-service-type= so that it is
>> > possible to configure Emacs using Guix home. This code is extremely
>> > preliminary hence I don't even think it is worth sending as a patch. Also I
>> > have never worked on a multi person Git project before and do not know how
>> > to solve the keyring error I get when using guix pull. I will outline what
>> > my code does and what features I would like to add.
>>
>> I am all for something like you describe, and the code you sent may be
>> good starting point!
>>
>> The rde project¹ by Andrew Tropin et al. may be a good source of
>> inspiration.  The “features” abstraction in particular seems to be
>> well-suited for Emacs.  But overall it’s reasonable to start small, with
>> a low-level approach to combine and configure Emacs packages.
>>
>> Thanks,
>> Ludo’.
>>
>> ¹ https://trop.in/rde/manual

-- 
Best regards,
Andrew Tropin

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Creating an Emacs Home Configuration Service
  2022-10-19 20:53     ` Zain Jabbar
  2022-10-20  7:22       ` Andrew Tropin
@ 2022-10-20 13:17       ` Ludovic Courtès
  1 sibling, 0 replies; 13+ messages in thread
From: Ludovic Courtès @ 2022-10-20 13:17 UTC (permalink / raw)
  To: Zain Jabbar; +Cc: guix-devel

Hi,

Zain Jabbar <zaijab2000@gmail.com> skribis:

> Thank you for showcasing Andrew Tropin's rde project. I believe the
> =features= abstraction have potential and make more intuitive sense
> for the design of configurable programs. There is a lot for me to
> learn from this design choice.
>
> As it stands, =features= are not in Guix proper, are there plans to
> merge them? How will they end up relating to the existing home
> services feature set?

I don’t think merging “features” into Guix has been discussed before.
It does sound like a logical next step to declarative configuration, but
I don’t have any experience to really say.

Anyway, I think the first step for Emacs configuration with Home is a
‘home-emacs-service-type’, possibly based on/inspired by the one in rde
that Andrew mentions.

Thanks,
Ludo’.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Creating an Emacs Home Configuration Service
  2022-10-17  2:34 ` Creating an Emacs Home Configuration Service Zain Jabbar
  2022-10-17 22:09   ` jbranso
  2022-10-19 15:36   ` Ludovic Courtès
@ 2022-10-20 18:35   ` Liliana Marie Prikler
  2 siblings, 0 replies; 13+ messages in thread
From: Liliana Marie Prikler @ 2022-10-20 18:35 UTC (permalink / raw)
  To: Zain Jabbar, guix-devel

Am Sonntag, dem 16.10.2022 um 16:34 -1000 schrieb Zain Jabbar:
> 2. Have Emacs update whenever the =home-environment= is updated.
> Meaning, if I did not add =(service emacs-evil-service-type)= in my
> =home-environment= then obviously =M-x evil-mode= should not work.
> But after adding the service then I want =M-x evil-mode= to work
> without having to restart Emacs. I do not understand the Emacs
> loading system on Guix well enough to know why it does not work.
> Skipping all of the =home-service= stuff, running =guix install
> emacs-evil-mode= then =(guix-emacs-autoload-packages)= does not let
> emacs know that =evil-mode= is installed. I would need to close Emacs
> and start Emacs again for Emacs to know about =evil-mode= being
> installed.
I suggest not doing this; there are good reasons why I disabled it.  If
you still want to, you can instruct your running emacs process to load
$GUIX_PROFILE/share/emacs/site-lisp/subdirs.el and perhaps also (guix-
emacs-autoload-packages).

Cheers


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2022-10-20 18:39 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CAH+UbWQ1JZCZf0BEOzT1zcTeW5sDekOsxbGYgKn8rjdQ5e0kUw@mail.gmail.com>
2022-10-17  2:34 ` Creating an Emacs Home Configuration Service Zain Jabbar
2022-10-17 22:09   ` jbranso
2022-10-17 23:12     ` Zain Jabbar
2022-10-18 15:41     ` jbranso
     [not found]       ` <CAH+UbWR8xWoCK9wouhsizEzTAO3CksNpkebu5we_75yQq++yUg@mail.gmail.com>
     [not found]         ` <a8142b002799224845f8efdddb28e518@dismail.de>
2022-10-19 18:18           ` jbranso
2022-10-19 20:25             ` Zain Jabbar
2022-10-19 20:56             ` jbranso
2022-10-19 21:09               ` Zain Jabbar
2022-10-19 15:36   ` Ludovic Courtès
2022-10-19 20:53     ` Zain Jabbar
2022-10-20  7:22       ` Andrew Tropin
2022-10-20 13:17       ` Ludovic Courtès
2022-10-20 18:35   ` Liliana Marie Prikler

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).