From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms1.migadu.com with LMTPS id uA8+O/+9Gma/ZAAA62LTzQ:P1 (envelope-from ) for ; Sat, 13 Apr 2024 19:16:48 +0200 Received: from aspmx1.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1.migadu.com with LMTPS id uA8+O/+9Gma/ZAAA62LTzQ (envelope-from ) for ; Sat, 13 Apr 2024 19:16:48 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; 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" ARC-Seal: i=1; s=key1; d=yhetil.org; t=1713028607; a=rsa-sha256; cv=none; b=oT6CYwzcwzSXbYWzfKKDiyXfRJ5hM71m/2ox7xlQWIRfMiZn9/eZZt5fyknmu1ExSOM32k Br5tYUK0ykCvCtH3Tu7ZQd+hNasOHu2Yt2db8nz0eRHMEbi3QgVetFyAGBpmWEM92EZrNw 2ioLQjXoIjgLNFhLuZ4VPS6muyjb5mwJ3QHVBhfkhIjHL/k7OcOvoAkMDBu5JLIklL6N8R Vfr2H6okvQDnteAQL/l3moPA3M1XiILIabNcUrNzu6wsCVAnN3lAggjzL1sQnS8w3uhU/N OFnrGOT22oYk5u/0/UVuBqR/St1E3C9wLLpAKh7ihekjjbyvyhCkZWN7RzYzoQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; 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" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1713028607; h=from:from:sender:sender:reply-to: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; bh=7i3HgjoRFcZ7W2dahVZxEOBU2SYrN8vei2CF9Xplvt8=; b=IVqXW0iHksDpftpkBujEBHkP3pXowfN6tie84vlR69GWaunncZCVVi+cEGreuCt2McfyMc bv9nPVI6MaPmC4+ITx8MiP1j4sD2FzdEH4U7RjnXiA0DupHBDYlNxoKdoAKuDaZA06OCz4 a8dJiK8ZpE0QMdqVqhYZScM9+gB2FrEiCzNS61xnVDPG3WFo9iRtluYK76xRw7WcYSgRS3 ZgwJ5Arv1TPC27jZ3+C+jww9BBcQ///VU5Oyyu32cm53KIQnySLwP2yb5F40hAiAINenh8 UrQy6Q2H0YRhHEDo+85Ta5Ubj/TcWiybvqPQl+N1q+sVZyjmgMLsCCTEvn8uow== 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 8D8BEFA12 for ; Sat, 13 Apr 2024 19:16:47 +0200 (CEST) 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 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 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 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) 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) 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 X-OVh-ClientIp: 81.67.146.208 To: Ludovic =?utf-8?Q?Court=C3=A8s?= , "Nicolas Graves via Development of GNU Guix and the GNU System distribution." Cc: emacs-devel@gnu.org, Andrew Tropin , Stefan Monnier Subject: Re: [Nicolas Graves] [PATCH v6 01/10] rde: emacs: Start emacs in --daemon mode, with shepherd and pid-file In-Reply-To: <87jzl22u5w.fsf@gnu.org> References: <20240410234923.29319-2-ngraves@ngraves.fr> <875xwotg35.fsf@trop.in> <87zfu0m9ps.fsf@ngraves.fr> <87jzl22u5w.fsf@gnu.org> Date: Sat, 13 Apr 2024 18:50:18 +0200 Message-ID: <87cyqtnr5h.fsf@ngraves.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Ovh-Tracer-Id: 13243960604207211189 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvledrudeiiedguddtkecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufgjfhffkfggtgfgsehtqhertddttdejnecuhfhrohhmpefpihgtohhlrghsucfirhgrvhgvshcuoehnghhrrghvvghssehnghhrrghvvghsrdhfrheqnecuggftrfgrthhtvghrnhepfeeitefhgffggefgtdejjeeluedvffehueeikeffueekfffhteetleegheevveegnecuffhomhgrihhnpehfrhgvvgguvghskhhtohhprdhorhhgpdhgnhhurdhorhhgnecukfhppeduvdejrddtrddtrddupdekuddrieejrddugeeirddvtdekpdefjedrheelrddugedvrddutddunecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepuddvjedrtddrtddruddpmhgrihhlfhhrohhmpehnghhrrghvvghssehnghhrrghvvghsrdhfrhdpnhgspghrtghpthhtohepuddprhgtphhtthhopehguhhigidquggvvhgvlhesghhnuhdrohhrghdpoffvtefjohhsthepmhhoheehtddpmhhouggvpehsmhhtphhouhht 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: , Reply-to: Nicolas Graves From: Nicolas Graves via "Development of GNU Guix and the GNU System distribution." Errors-To: guix-devel-bounces+larch=yhetil.org@gnu.org Sender: guix-devel-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Spam-Score: -6.88 X-Migadu-Queue-Id: 8D8BEFA12 X-Migadu-Spam-Score: -6.88 X-Migadu-Scanner: mx10.migadu.com X-TUID: r/5d0UBT2+DC 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