From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id 4DMHF/vJTmOtYAAAbAwnHQ (envelope-from ) for ; Tue, 18 Oct 2022 17:44:59 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id ENgUF/vJTmOK5gAA9RJhRA (envelope-from ) for ; Tue, 18 Oct 2022 17:44:59 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id F219C946E for ; Tue, 18 Oct 2022 17:44:58 +0200 (CEST) Received: from localhost ([::1]:38872 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1okom1-0000Gl-Oy for larch@yhetil.org; Tue, 18 Oct 2022 11:44:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40818) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okoj9-0000AC-U3 for guix-devel@gnu.org; Tue, 18 Oct 2022 11:42:00 -0400 Received: from mx1.dismail.de ([78.46.223.134]:46969) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okoiu-00027e-3r for guix-devel@gnu.org; Tue, 18 Oct 2022 11:41:59 -0400 Received: from mx1.dismail.de (localhost [127.0.0.1]) by mx1.dismail.de (OpenSMTPD) with ESMTP id 1f3a7151; Tue, 18 Oct 2022 17:41:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=dismail.de; h= mime-version:date:content-type:content-transfer-encoding:from :message-id:subject:to:cc:in-reply-to:references; s=20190914; bh=d43LAP5plc/jO/+1eWbF4zcVtkZKiONUNxdK6e7mA3o=; b=YIufUaMqf/nE nLUQilRCzTYTq0Fu0O7WqpMc3sa9o7kpGQ22HIUJHGl3EmondOkpTs4d7qaaQP5+ jkKTmLCkxsYaFk0/kDFu2EjJxP3uRFPnDXi55chKOYZ7G/wMDSYBss+YWsw70leu t0oucQfAzPoORMG+jLKwxhWTs7ZgV9f1UPRo4WD5IgDgeEPBv9mgD93aJiV7YkPM Yrxzy7jqtApglK2qQW1mRxEkLOgKF6O2K4HeVvMHHXBXbSDugDX6fFumdsG8xtvO 8pZFiu0LaX45dxCWzaC7V9EAZKTI78zZ94qAZxn7bY4xFvQwuLW71G7LH9P9XS6x beRZjtEXbA== Received: from smtp1.dismail.de ( [10.240.26.11]) by mx1.dismail.de (OpenSMTPD) with ESMTP id d655644e; Tue, 18 Oct 2022 17:41:40 +0200 (CEST) Received: from smtp1.dismail.de (localhost [127.0.0.1]) by smtp1.dismail.de (OpenSMTPD) with ESMTP id 7f65c3eb; Tue, 18 Oct 2022 17:41:40 +0200 (CEST) Received: by dismail.de (OpenSMTPD) with ESMTPSA id a54d0ef2 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Tue, 18 Oct 2022 17:41:39 +0200 (CEST) MIME-Version: 1.0 Date: Tue, 18 Oct 2022 15:41:38 +0000 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Mailer: RainLoop/1.16.0a From: jbranso@dismail.de Message-ID: <8b00165ff49030fdd11708cb1fd4a5b9@dismail.de> Subject: Re: Creating an Emacs Home Configuration Service To: "Zain Jabbar" Cc: guix-devel@gnu.org In-Reply-To: References: <331c0017d7a4842fd2919b330a3d3894@dismail.de> Received-SPF: pass client-ip=78.46.223.134; envelope-from=jbranso@dismail.de; helo=mx1.dismail.de X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: guix-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+larch=yhetil.org@gnu.org Sender: "Guix-devel" X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1666107899; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=faMjoLuZDQX5l56RHkeVNVFAf++nE3kRP8dWIzWW1MU=; b=lxq//2uL2ohJSKxKn9lAV/G7yDbeu2TuO8I6aMpjHpqylgMbgMBZ9yjxN24q8WdgqzeVjF Ecag352nSdDYU4GlwXTuNU00FCU+/+tjZtwutmFly+CcNSn8lVii9IEHwVS3CH1ctSITS9 pq9Ctr+SGyG4UHdWC1vRFewCWcBR7xHfGWFG0f+pYQssZDCoNU1LtUoLmu7hFK00qVtW5w SgTAUdu+g07bKbPYfcZv4Ur4Qd/3L2ZOv6avjZr2NW/ksfi9iFnd4bAaft4yLNVtDKbJHC MmR9MYGukz8z0whdpuZTGXsLh3qgOrGFMpZV8IyLyjuUSOkeH03L2ajxOaLUBw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1666107899; a=rsa-sha256; cv=none; b=dOh6nj8mbdj8ClCXA58aN6+I64Uf2uEd4/M+lOxzUT9QU8GNh7Z0LS6LWL22P8PeZiJf0y tE3QMtUYEifIHZNfI72Fvlfj83bmDCke4zPyn5s4nNFA1RgJTY39qVI7AfQEHELcjUIpDB f5wBicYcf0bvo5tRsICfuogsfB6AB1gJ6mZXSl8QAKytbKnrehBO3qqWgAWwlguC51X6pr Jy0/sn0ZFYUInDgLOW/VBcv1o2+DCvxaxt9zdI0GyfVgVtwHPa5R2N5JtKxV6eO7P2ffdL 7lfDm+99fY9ZxZPU/7Ij386kJTAMJHzjtu9ZRenpWjW+LzKjO7fZqaUIxoNbAg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=dismail.de header.s=20190914 header.b=YIufUaMq; dmarc=pass (policy=reject) header.from=dismail.de; spf=pass (aspmx1.migadu.com: domain of "guix-devel-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-devel-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -5.02 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=dismail.de header.s=20190914 header.b=YIufUaMq; dmarc=pass (policy=reject) header.from=dismail.de; spf=pass (aspmx1.migadu.com: domain of "guix-devel-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-devel-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: F219C946E X-Spam-Score: -5.02 X-Migadu-Scanner: scn1.migadu.com X-TUID: Zn81Yql1Tbf4 October 17, 2022 7:12 PM, "Zain Jabbar" wrote: > Aloha Guix Development Team, >=20 >=20Thank 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. >=20 >=20First, I define a configuration (without serialization currently). >=20 >=20#+BEGIN_SRC scheme > (define file-likes? (list-of file-like?)) >=20 >=20(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 >=20 >=20Then, I define an =3Demacs-configuration-service=3D that takes in a > configuration. This service will add packages in the =3Demacs-packages= =3D > to the profile, and append the S-Expressions in =3Dearly-init=3D and > =3Dinit=3D to $XDG_CONFIG_HOME/emacs/early-init.el and > $XDG_CONFIG_HOME/emacs/init.el respectively. The service has > definition, >=20 >=20#+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 >=20 >=20This 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. >=20 >=20#+BEGIN_SRC scheme > (define evil-configuration > (emacs-configuration > (emacs-packages (list (specification->package "emacs-evil"))) > (init '((evil-mode 1))))) >=20 >=20(define vertico-configuration > (emacs-configuration > (emacs-packages (list (specification->package "emacs-vertico"))) > (init '((vertico-mode 1))))) >=20 >=20(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 >=20 >=20We 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 > =3Demacs-configurations=3D in the current module and append them that w= ay. >=20 >=20#+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) >=20 >=20(filter emacs-configuration? > (map variable-ref > (filter variable-bound? > (hash-map->list (lambda (x y) y) (struct-ref (current-module) 0))))))) > #+END_SRC >=20 >=20What 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. >=20 >=20On Mon, Oct 17, 2022 at 12:09 PM wrote: >=20 >>=20October 17, 2022 2:38 AM, "Zain Jabbar" wrote= : >>=20 >>=20Aloha Guix Development Team, >>=20 >>=20Running =3Dguix home search emacs=3D returns nothing. I also could n= ot find an email using =3DC-u M-x >> debbugs-gnu=3D about an Emacs configuration service. >>=20 >>=20This is my first email to this mailing address. Please give me point= ers on formatting and further >> improvements. >>=20 >>=20I think you sent an html email. Generally you want to send plain tex= t emails. :) >>=20 >>=20I have attempted to make an =3Demacs-home-service-type=3D 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 c= ode does and what features I >> would like to add. >>=20 >>=20#+BEGIN_SRC scheme >> (define* (emacs-configuration-service name #:key (init '()) (early-ini= t '()) (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"))) >>=20 >>=20(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 >>=20 >>=20I define a general configuration service generator which takes in fo= ur things: >> 1. The =3Dname=3D of the service >> 2. The configuration to be ran in =3Dinit.el=3D >> 3. The configuration to be ran in =3Dearly-init.el=3D >> 4. The packages in Guix to be added to the =3Dhome-profile=3D. >>=20 >>=20After giving the =3Dname=3D, =3Dpackages=3D, and =3Dconfig.el=3D fil= es we get a new service type that we can >> add to our home declaration. This service will then add a file in >> =3D~/.config/emacs/services/emacs-{NAME}-configuration.el=3D. I then h= ave another service that places >> an =3Dinit.el=3D which loads everything in the service directory. >>=20 >>=20If we want to install and configure =3Devil-mode=3D using this =3Dho= me-service=3D we may define the >> following somewhere. >>=20 >>=20#+BEGIN_SRC scheme >> (define-public emacs-evil-service-type >> (emacs-configuration-service >> 'evil #:emacs-packages (list emacs-evil) >> #:init '((evil-mode 1)))) >> #+END_SRC >>=20 >>=20Within our =3Dhome-environment=3D we may add the service using: >>=20 >>=20#+BEGIN_SRC scheme >> (home-environment >> ;; ...Things in the home-environment... >> (services >> (list >> ;; ...Other Services... >> (service emacs-evil-service-type)))) >> #+END_SRC >>=20 >>=20There are some missing features I want to add. >>=20 >>=201. Have the =3Dhome-emacs-*-service-type=3D service-types add to the= =3Dinit.el=3D directly rather than >> within a folder to be loaded. I couldn't add two files with the same n= ame to the store. So I have >> emacs-evil.el in the store to be placed separately later=20rather than= appending to the existing >> init.el file. >>=20 >>=202. Have Emacs update whenever the =3Dhome-environment=3D is updated.= Meaning, if I did not add >> =3D(service emacs-evil-service-type)=3D in my =3Dhome-environment=3D t= hen obviously =3DM-x evil-mode=3D should >> not work. But after adding the service then I want =3DM-x evil-mode=3D= to work without having to >> restart Emacs. I do not understand the Emacs loading system on Guix we= ll enough to know why it does >> not work. Skipping all of the =3Dhome-service=3D stuff, running =3Dgui= x install emacs-evil-mode=3D then >> =3D(guix-emacs-autoload-packages)=3D does not let emacs know that =3De= vil-mode=3D is installed. I would >> need to close Emacs and start Emacs again for Emacs to know about =3De= vil-mode=3D being installed. >>=20 >>=203. Use configurations somehow. I have completely neglected this feat= ure in my system. I do not know >> what would be useful there. >>=20 >>=20I believe that you are referring to using scheme records to configur= e the emacs service. :) >>=20 >>=20I would recommend using (define-configuration ...) procedure. >>=20 >>=20(There is a define-record-type* as well, but I think the consensus i= s that >> define-configuration* is a little easier to use. Does better error han= dling >> and can help you generate documentation from the code). >>=20 >>=20You can find examples of that here: >>=20 >>=20https://git.savannah.gnu.org/cgit/guix.git/tree/gnu/services/mail.sc= m >>=20 >>=20-- >> Thank you, >> Zain Jabbar >=20 >=20-- > Thank you, > Zain Jabbar >=20 >=20On Mon, Oct 17, 2022 at 12:09 PM wrote: >=20 >>=20October 17, 2022 2:38 AM, "Zain Jabbar" wrote= : >>=20 >>=20Aloha Guix Development Team, >>=20 >>=20Running =3Dguix home search emacs=3D returns nothing. I also could n= ot find an email using =3DC-u M-x >> debbugs-gnu=3D about an Emacs configuration service. >>=20 >>=20This is my first email to this mailing address. Please give me point= ers on formatting and further >> improvements. >>=20 >>=20I think you sent an html email. Generally you want to send plain tex= t emails. :) >>=20 >>=20I have attempted to make an =3Demacs-home-service-type=3D 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 c= ode does and what features I >> would like to add. >>=20 >>=20#+BEGIN_SRC scheme >> (define* (emacs-configuration-service name #:key (init '()) (early-ini= t '()) (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"))) >>=20 >>=20(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 >>=20 >>=20I define a general configuration service generator which takes in fo= ur things: >> 1. The =3Dname=3D of the service >> 2. The configuration to be ran in =3Dinit.el=3D >> 3. The configuration to be ran in =3Dearly-init.el=3D >> 4. The packages in Guix to be added to the =3Dhome-profile=3D. >>=20 >>=20After giving the =3Dname=3D, =3Dpackages=3D, and =3Dconfig.el=3D fil= es we get a new service type that we can >> add to our home declaration. This service will then add a file in >> =3D~/.config/emacs/services/emacs-{NAME}-configuration.el=3D. I then h= ave another service that places >> an =3Dinit.el=3D which loads everything in the service directory. >>=20 >>=20If we want to install and configure =3Devil-mode=3D using this =3Dho= me-service=3D we may define the >> following somewhere. >>=20 >>=20#+BEGIN_SRC scheme >> (define-public emacs-evil-service-type >> (emacs-configuration-service >> 'evil #:emacs-packages (list emacs-evil) >> #:init '((evil-mode 1)))) >> #+END_SRC >>=20 >>=20Within our =3Dhome-environment=3D we may add the service using: >>=20 >>=20#+BEGIN_SRC scheme >> (home-environment >> ;; ...Things in the home-environment... >> (services >> (list >> ;; ...Other Services... >> (service emacs-evil-service-type)))) >> #+END_SRC >>=20 >>=20There are some missing features I want to add. >>=20 >>=201. Have the =3Dhome-emacs-*-service-type=3D service-types add to the= =3Dinit.el=3D directly rather than >> within a folder to be loaded. I couldn't add two files with the same n= ame to the store. So I have >> emacs-evil.el in the store to be placed separately later rather than a= ppending to the existing >> init.el file. >>=20 >>=202. Have Emacs update whenever the =3Dhome-environment=3D is updated.= Meaning, if I did not add >> =3D(service emacs-evil-service-type)=3D in my =3Dhome-environment=3D t= hen obviously =3DM-x evil-mode=3D should >> not work. But after adding the service then I want =3DM-x evil-mode=3D= to work without having to >> restart Emacs. I do not understand the Emacs loading system on Guix we= ll enough to know why it does >> not work. Skipping all of the =3Dhome-service=3D stuff, running =3Dgui= x install emacs-evil-mode=3D then >> =3D(guix-emacs-autoload-packages)=3D does not let emacs know that =3De= vil-mode=3D is installed. I would >> need to close Emacs and start Emacs again for Emacs to know about =3De= vil-mode=3D being installed. >>=20 >>=203. Use configurations somehow. I have completely neglected this feat= ure in my system. I do not know >> what would be useful there. >>=20 >>=20I believe that you are referring to using scheme records to configur= e the emacs service. :) >>=20 >>=20I would recommend using (define-configuration ...) procedure. >>=20 >>=20(There is a define-record-type* as well, but I think the consensus i= s that >> define-configuration* is a little easier to use. Does better error han= dling >> and can help you generate documentation from the code). >>=20 >>=20You can find examples of that here: >>=20 >>=20https://git.savannah.gnu.org/cgit/guix.git/tree/gnu/services/mail.sc= m 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 y= our 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=20 package=20store?=20=20 Thanks, Joshua >>=20 >> -- >> Thank you, >> Zain Jabbar >=20 >=20-- > Thank you, > Zain Jabbar