From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Nicolas Graves via "Development of GNU Guix and the GNU System distribution." Newsgroups: gmane.comp.gnu.guix.devel,gmane.emacs.devel Subject: Re: [Nicolas Graves] [PATCH v6 01/10] rde: emacs: Start emacs in --daemon mode, with shepherd and pid-file Date: Sat, 13 Apr 2024 18:50:18 +0200 Message-ID: <87cyqtnr5h.fsf@ngraves.fr> References: <20240410234923.29319-2-ngraves@ngraves.fr> <875xwotg35.fsf@trop.in> <87zfu0m9ps.fsf@ngraves.fr> <87jzl22u5w.fsf@gnu.org> Reply-To: Nicolas Graves Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="37394"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org, Andrew Tropin , Stefan Monnier To: Ludovic =?utf-8?Q?Court=C3=A8s?= , "Nicolas Graves via Development of GNU Guix and the GNU System distribution." Original-X-From: guix-devel-bounces+gcggd-guix-devel=m.gmane-mx.org@gnu.org Sat Apr 13 18:51:10 2024 Return-path: Envelope-to: gcggd-guix-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rvgar-0009UK-JD for gcggd-guix-devel@m.gmane-mx.org; Sat, 13 Apr 2024 18:51:09 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rvgaH-000306-DX; Sat, 13 Apr 2024 12:50:34 -0400 Original-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 1rvgaD-0002zl-1H for guix-devel@gnu.org; Sat, 13 Apr 2024 12:50:29 -0400 Original-Received: from 19.mo550.mail-out.ovh.net ([178.32.97.206]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rvga8-0002sx-Az for guix-devel@gnu.org; Sat, 13 Apr 2024 12:50:27 -0400 Original-Received: from director9.ghost.mail-out.ovh.net (unknown [10.108.9.185]) by mo550.mail-out.ovh.net (Postfix) with ESMTP id 4VGzvJ45CTz1Htc for ; Sat, 13 Apr 2024 16:50:20 +0000 (UTC) Original-Received: from ghost-submission-6684bf9d7b-4f5wq (unknown [10.110.113.27]) by director9.ghost.mail-out.ovh.net (Postfix) with ESMTPS id DC9461FDAC; Sat, 13 Apr 2024 16:50:19 +0000 (UTC) Original-Received: from ngraves.fr ([37.59.142.101]) by ghost-submission-6684bf9d7b-4f5wq with ESMTPSA id EZjvMcu3GmafFBwABm/Oag (envelope-from ); Sat, 13 Apr 2024 16:50:19 +0000 Authentication-Results: garm.ovh; auth=pass (GARM-101G0047e392178-635f-4ef2-8423-838134737a58, 680F127F37A04776A64DED9A59A7121AD484C431) smtp.auth=ngraves@ngraves.fr X-OVh-ClientIp: 81.67.146.208 In-Reply-To: <87jzl22u5w.fsf@gnu.org> X-Ovh-Tracer-Id: 13243960604207211189 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvledrudeiiedguddtkecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufgjfhffkfggtgfgsehtqhertddttdejnecuhfhrohhmpefpihgtohhlrghsucfirhgrvhgvshcuoehnghhrrghvvghssehnghhrrghvvghsrdhfrheqnecuggftrfgrthhtvghrnhepfeeitefhgffggefgtdejjeeluedvffehueeikeffueekfffhteetleegheevveegnecuffhomhgrihhnpehfrhgvvgguvghskhhtohhprdhorhhgpdhgnhhurdhorhhgnecukfhppeduvdejrddtrddtrddupdekuddrieejrddugeeirddvtdekpdefjedrheelrddugedvrddutddunecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepuddvjedrtddrtddruddpmhgrihhlfhhrohhmpehnghhrrghvvghssehnghhrrghvvghsrdhfrhdpnhgspghrtghpthhtohepuddprhgtphhtthhopehguhhigidquggvvhgvlhesghhnuhdrohhrghdpoffvtefjohhsthepmhho heehtddpmhhouggvpehsmhhtphhouhht Received-SPF: pass client-ip=178.32.97.206; envelope-from=ngraves@ngraves.fr; helo=19.mo550.mail-out.ovh.net X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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+gcggd-guix-devel=m.gmane-mx.org@gnu.org Original-Sender: guix-devel-bounces+gcggd-guix-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.comp.gnu.guix.devel:69915 gmane.emacs.devel:317713 Archived-At: On 2024-04-12 22:38, Ludovic Court=C3=A8s wrote: > Hi Nicolas, > > Nicolas Graves skribis: > >> As promised to Stefan a few months ago, here's a use case of >> Shepherd/Emacs implementation that we developped in RDE. > > Would be nice to have it in Guix Home! Something like this seems to work: (define (emacs-shepherd-service config name) (shepherd-service (documentation (format #f "Emacs server. Use ~a to connect to it." (if (eq? 'server name) "@code{emacsclient}" (format #f "@code{emacsclient -s ~a}" name)))) (provision `(,(symbol-append 'emacs- name))) (requirement '(emacs)) (modules '((shepherd support))) ;for '%user-runtime-dir' (start #~(make-systemd-constructor (list #$(file-append (home-emacs-configuration-emacs config) "/bin/emacs") #$(format #f "--fg-daemon=3D~a" name)) (list (endpoint (make-socket-address AF_UNIX (string-append %user-runtime-dir "/emacs/" #$(symbol->string name))) #:name '#$(format #f "emacs-~a" name) #:socket-directory-permissions #o700)) #:log-file (string-append (getenv "XDG_STATE_HOME") "/log" "/emacs-" #$(symbol->string name) ".log"))) (stop #~(make-systemd-destructor)))) But I'm not sure it's better regarding user experience. On RDE we implemented a notifier that parses the result of herd eval root "(and=3D> (lookup-service 'emacs-server) service-status)" thus giving a nice "Emacs is currently starting" notification. This evaluation doesn't seem to work using make-systemd-constructor, although it has its advantages (indeed launches a frame when available). It would be nice if service-status could "sync" with make-systemd-constructor in this case. I would be happy to send such a patch for Guix (is there already some patch series on which to graft this?), WDYT @Ludo? I can also send this in RDE, it simplifies a lot although I'm still not sure it yields a better user experience. @Andrew? >> We're using the --daemon option on the Shepherd side to launch the >> server in the background, include code in Emacs configuration to make it >> create a pid-file as soon as the server has started, and redefine >> kill-emacs to be managed by the Shepherd. > > Emacs supports systemd-style socket activation so, instead of using a > PID file, you could use =E2=80=98make-systemd-constructor=E2=80=99. > > Now, that code in emacs.c is unfortunately implemented via libsystemd > and thus disabled in Guix. Using libsystemd in this case is unnecessary > (and increases the attack surface, as we=E2=80=99ve seen with the xz back= door): > it could read the =E2=80=98LISTEN_FDS=E2=80=99 and =E2=80=98LISTEN_PID=E2= =80=99 environment variables > instead of calling the sd_* functions. > > https://www.freedesktop.org/software/systemd/man/latest/sd_listen_fds.h= tml > https://www.gnu.org/software/shepherd/manual/html_node/Service-De_002d-= and-Constructors.html#index-make_002dsystemd_002dconstructor > > Thanks, > Ludo=E2=80=99. --=20 Best regards, Nicolas Graves