From patchwork Sat Oct 22 07:09:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Zain Jabbar X-Patchwork-Id: 43816 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 5C20C27BBEB; Sat, 22 Oct 2022 08:42:31 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 5710B27BBEA for ; Sat, 22 Oct 2022 08:42:29 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1om8e3-00079i-E4; Sat, 22 Oct 2022 03:10:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1om8dv-00074A-KI for guix-patches@gnu.org; Sat, 22 Oct 2022 03:10:06 -0400 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1om8du-00026u-V3 for guix-patches@gnu.org; Sat, 22 Oct 2022 03:10:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1om8du-0001CB-Fa for guix-patches@gnu.org; Sat, 22 Oct 2022 03:10:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#58652] Creating home-emacs-service-type Resent-From: Zain Jabbar Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 22 Oct 2022 07:10:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58652 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: To: Liliana Marie Prikler Cc: 58652@debbugs.gnu.org, jbranso@dismail.de Received: via spool by 58652-submit@debbugs.gnu.org id=B58652.16664225944577 (code B ref 58652); Sat, 22 Oct 2022 07:10:02 +0000 Received: (at 58652) by debbugs.gnu.org; 22 Oct 2022 07:09:54 +0000 Received: from localhost ([127.0.0.1]:39616 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1om8dl-0001Bl-O9 for submit@debbugs.gnu.org; Sat, 22 Oct 2022 03:09:54 -0400 Received: from mail-ed1-f45.google.com ([209.85.208.45]:42581) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1om8di-0001BW-Tq for 58652@debbugs.gnu.org; Sat, 22 Oct 2022 03:09:52 -0400 Received: by mail-ed1-f45.google.com with SMTP id u21so13511238edi.9 for <58652@debbugs.gnu.org>; Sat, 22 Oct 2022 00:09:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=b9JQvhEX+Xg1p2ahPNOzFpOn/KYkut3GyFvdPWgHNZg=; b=KzuEl2+/xgXu1GHpnvl8HwQOdtAKuOP4mHPoYHhizMYSyCaRmztbT9RvQVIgurBl1d pGQeiC/yLvWXhdMQFt5wlQWiCrAJp0xz0tzpLVQscIr/W8MCPsqm85BxQSdXuEbmXtFL Ebx9jzSHCFaivEfu4BH+8UHhKVaCXtFUitsRre6UFR9/BjX0b3UaYWIHRty4J+6AoM0z dehkSTKYjx17VqxrunSB4CpaJA+JzP46vxs62DrK/dxRLvQ8+dSJBFKo24iSg6LVD/7X Ju4C5FadvWnRgjlNx9E8FdPOjvejpwfCPviWuJC0W6f/s/nsZaDIR3ozTBDePvqTih5v meLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=b9JQvhEX+Xg1p2ahPNOzFpOn/KYkut3GyFvdPWgHNZg=; b=CquekbWilXscvp4cLhs/xxn4XHc0ET0NyqSzP7DdQ3NQRf9cMwQgc/0U5UBKPqhHtQ RjwnCWDfpfZFnhlTF4+l/JA52qsbW8JORytTQlJbw12V+ycjm7C6VBlZOMpMUFu013EQ Rk63hiqDXn/wKZqpcbVjoQmk0AJgVvtJbN6uWmHxb097kVjIs1ayEMJBeO0G+qPKngbf Zi7w83KGR9QCa7VYkkxpDVk2tw4m8S52/Ly638brYMSyeEuJ67VCnqB8zNyB+4Mgsoh4 NsHOjFoXSCRWcrOBQlYNs535h4NKeNPAr4/yJRKmnIe7Cd/oXKElzNSAzpRfaMH0h9FH 2X7w== X-Gm-Message-State: ACrzQf3il7Alk73KaET/ICz5wLfLkBfSeA5QItKlWgaY31OGr45Vz28z x7jvOH4DaLIVXe6Sbp9d9gDe1zVRV4ZXyMIbEoc= X-Google-Smtp-Source: AMsMyM7YJzN1Sxz4RhSmBABZdM7xBsUGGHzB+1fSM3+jl3h9mZlwQP78OZbfpXoFGs/pIhWC2BXTvrHujgDNsIS+hkQ= X-Received: by 2002:a17:907:1c10:b0:791:a716:5089 with SMTP id nc16-20020a1709071c1000b00791a7165089mr15256274ejc.672.1666422584732; Sat, 22 Oct 2022 00:09:44 -0700 (PDT) MIME-Version: 1.0 References: <495a0fab9b20dd40f9fb1aef2261b60e053bf5cd.camel@ist.tugraz.at> <77fbe7e648edfc15c8007616199a867dbae72b71.camel@ist.tugraz.at> In-Reply-To: <77fbe7e648edfc15c8007616199a867dbae72b71.camel@ist.tugraz.at> From: Zain Jabbar Date: Fri, 21 Oct 2022 21:09:33 -1000 Message-ID: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Guix-patches" Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches Aloha All, Apologies for the delay. > Instead of 6+7, write a single commit and use =git format-patch=. Understood. Used =git format-patch HEAD~1= after =git reset --hard origin/HEAD= to only have a single commit. > Is that #:splice? #t meant to be there? Yes, I believe so. Without the =#:splice? #:t= everything within the file is surrounded by parenthesis. For example #+BEGIN_SRC scheme (use-modules (gnu home services emacs) (gnu home) (guix gexp) (gnu packages) (ice-9 pretty-print) (gnu services)) (home-environment (services (list (service home-emacs-service-type (home-emacs-configuration (packages (list (specification->package "bash") (specification->package "emacs-next"))) (extra-files (list (scheme-file "greetings" '((setq x 42) (setq y 10)) #:splice? #:t)))))))) #+END_SRC Places =(setq x 42)(setq y 10)= (no whitespace so it's kind of hard to read) in =greetings=. That would properly run as Elisp. Without the splicing we obtain =((setq x 42) (setq y 10))= which assumes we will call a function =(setq x 42)= on the argument =(setq y 10)= which will not work. > Also, why is bash required here? Bash was there for debugging purposes. You are right though, it does not make a lot of sense to be there. It should be in the =home-environment= =packages= not in the =home-emacs-configuration=. Surprisingly if =bash= was not installed, =sh= was nowhere to be found from within =guix home container ${FILE}= and Emacs info manuals were not readable (something Joshua Branson helped me iron out). > You should perhaps also distinguish > the emacs package and the emacs-* packages like so: > (emacs emacs-next) > (packages (list emacs-dash emacs-tempel)) Attached is a patch with =emacs= as a configuration type and here is an example =home-environment= where =bash= installed using the =packages= slot. #+BEGIN_SRC scheme (use-modules (gnu home services emacs) (gnu home) (guix gexp) (gnu packages) (ice-9 pretty-print) (gnu services)) (home-environment (packages (list (specification->package "bash"))) (services (list (service home-emacs-service-type)))) #+END_SRC In the guix-dev mailing list, it has been discussed that Andrew Tropin's method of declaring a config is worthwhile inspiration. Here is an example configuration block. #+BEGIN_SRC scheme (define emacs-configure-rde-keymaps (rde-emacs-configuration-package 'rde-keymaps `((defvar rde-app-map nil "Prefix keymap for applications.") (define-prefix-command 'rde-app-map nil) (defvar rde-toggle-map nil "\ Prefix keymap for binding various minor modes for toggling functionalitty.") (define-prefix-command 'rde-toggle-map nil)) #:summary "Keymaps inteded for reuse among configure-* packages")) #+END_SRC This is a bit closer to the current patch using S-Expressions over files. Perhaps I should wait for more people to chime in. Maybe I can try to please both sides. Make a conditional, if the =init= or =early-init= form is empty (as it is by default) then allow for a file named =init.el= in the =extra-files= argument. On Thu, Oct 20, 2022 at 8:06 PM Liliana Marie Prikler wrote: > > Am Donnerstag, dem 20.10.2022 um 11:30 -1000 schrieb Zain Jabbar: > > Aloha All, > > > > Thank you for your input. > > > > > Note that you reverted the patch direction. > > > > Please forgive me for that. Is it possible to explain what I did > > wrong? I will outline my steps to help you figure out what I did > > incorrectly. > > > > 1. I cloned the repo > > 2. Used =guix shell -D guix= > > 3. Ran =./bootstrap= > > 4. Ran =./configure --localstatedir=/var= > > 5. Ran =make && make check=. By the way, my =make check= had a failed > > test, I don't know if that was expected. > > 6. Made some commits > > 7. I used =git diff HEAD origin/HEAD > my-guix-patch.patch=. > > > > I might have messed around too much in my cloned repo, throwing > > something off. > Instead of 6+7, write a single commit and use =git format-patch=. > > You can of course do multi-patch series, but this feature seems not to > be one that requires that. Always clean up your commit log after a > hacking session ;) > > > > You should also take an extra-files argument, e.g. to add custom.el > > > or other elisp files that init.el might refer to. > > > > Understood. Attached as a new patch. =home-emacs-configuration= now > > has an extra field =extra-files=. To use it, input a list of file > > objects. The service will splice them into > > =$XDG_CONFIG_HOME/emacs/{FILE}=. Here is an example configuration. > > Using =guix home container= will allow you to see the file > > =greetings= > > with contents "hello world" in =.config/emacs/=. > > > > #+BEGIN_SRC scheme > > (use-modules (gnu home services emacs) > > (gnu home) > > (guix gexp) > > (gnu packages) > > (ice-9 pretty-print) > > (gnu services)) > > > > (home-environment > > (services > > (list > > (service home-emacs-service-type > > (home-emacs-configuration > > (packages > > (list > > (specification->package "bash") > > (specification->package "emacs-next"))) > > (extra-files (list (scheme-file "greetings" '(hello world) > > #:splice? #:t)))))))) > > #+END_SRC > Is that #:splice? #t meant to be there? > > Also, why is bash required here? You should perhaps also distinguish > the emacs package and the emacs-* packages like so: > > (emacs emacs-next) > (packages (list emacs-dash emacs-tempel)) > > As a future extension, it'd be nice if we could use this service to > easily specify native compilation for emacs packages, but for this one > would have to lay some groundwork in emacs-build-system. > > > > Also, I'm not certain if "scheme-file" is the right primitive here > > > – Emacs Lisp does differ from Scheme, e.g. in keyword syntax among > > > others. > > > > I agree; using =scheme-file= for =emacs-lisp= feels blasphemous. > > There are some odd errors associated with this method too. For > > example, =#'foo= is the shorthand for =(function foo)= in Emacs Lisp > > but gets turned into =(syntax foo)= when using Guile. Meaning a pure > > drag and drop =init.el >> guile-sexp= has some things that need to be > > changed. > > The fact that Emacs-Lisp and Guile Scheme use S-Expressions was > > something I wanted to leverage. It becomes easy to write Elisp in the > > parens of the =init= parameter because there is no context switching > > (e.g. lispy works, cape-symbols works for Elisp in Scheme). > Note that Guile has an elisp reader, albeit a broken one, but no means > to switch languages inside files. > > > I am open to other forms of inputting the text in the files. This is > > a bit high maka maka, but I would also like to see how "elegant" the > > other methods of inserting Elisp look. That is, can we make it > > desirable for people to integrate Elisp into Guile Scheme moreso than > > a =local-file= declaration. Using backquotes and S-Expressions allows > > for some variables from Guile to be placed into the Emacs > > configuration like the system type, user names, and emails. > I think taking a list of file-like objects and concatenating their > contents might be worth considering. That's a bit more overhead, but > we'd have a cleaner separation between fragments that have the same > semantics in Scheme and those that don't. > > Cheers From e39ea1708d5b7121cac9a9f6c7953c15633b01c0 Mon Sep 17 00:00:00 2001 From: Zain Jabbar Date: Fri, 21 Oct 2022 20:48:31 -1000 Subject: [PATCH] Adding =home-emacs-service-type= and =home-emacs-configuration=. A service to configure emacs using guix home. --- gnu/home/services/emacs.scm | 72 +++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 gnu/home/services/emacs.scm diff --git a/gnu/home/services/emacs.scm b/gnu/home/services/emacs.scm new file mode 100644 index 0000000000..1da6987411 --- /dev/null +++ b/gnu/home/services/emacs.scm @@ -0,0 +1,72 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2022 Zain Jabbar +;;; +;;; This file is part of GNU Guix. +;;; +;;; GNU Guix is free software; you can redistribute it and/or modify it +;;; under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 3 of the License, or (at +;;; your option) any later version. +;;; +;;; GNU Guix is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with GNU Guix. If not, see . + +(define-module (gnu home services emacs) + #: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) + + #:export (home-emacs-service-type + home-emacs-configuration)) + +(define file-likes? (list-of file-like?)) + +(define-configuration/no-serialization home-emacs-configuration + (emacs + (file-like (specification->package "emacs-next")) + "The Emacs package to use.") + (packages + (file-likes '()) + "The packages this configuration will add to home-profile. Usually these will be emacs-* packages.") + (early-init + (list '()) + "A list whose contents will inserted into @file{$XDG_CONFIG_HOME/emacs/early-init.el}") + (init + (list '()) + "A list whose contents will inserted into @file{$XDG_CONFIG_HOME/emacs/init.el}") + (extra-files + (file-likes '()) + "A list of files to be placed in @file{$XDG_CONFIG_HOME/emacs/}.")) + +(define home-emacs-service-type + (service-type (name 'emacs-configuration) + (extensions + (list (service-extension + home-profile-service-type + (lambda (config) `(,(home-emacs-configuration-emacs config) + ,@(home-emacs-configuration-packages config)))) + (service-extension + home-xdg-configuration-files-service-type + (lambda (config) + `(("emacs/early-init.el" + ,(scheme-file "early-init.el" + (home-emacs-configuration-early-init config) + #:splice? #:t)) + ("emacs/init.el" + ,(scheme-file "init.el" + (home-emacs-configuration-init config) + #:splice? #:t)) + ,@(map (lambda (file) (list (string-append "emacs/" (scheme-file-name file)) + file)) + (home-emacs-configuration-extra-files config))))))) + (default-value (home-emacs-configuration)) + (description "Configures Emacs and installs packages to home-profile."))) -- 2.38.0