From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id qH8eD8GBUGINMgAAgWs5BA (envelope-from ) for ; Fri, 08 Apr 2022 20:41:05 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id WBPjC8GBUGK0DAAAauVa8A (envelope-from ) for ; Fri, 08 Apr 2022 20:41:05 +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 DAE633C973 for ; Fri, 8 Apr 2022 20:41:04 +0200 (CEST) Received: from localhost ([::1]:38160 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nctXc-00035W-2F for larch@yhetil.org; Fri, 08 Apr 2022 14:41:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45922) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nctXB-000359-IM for guix-devel@gnu.org; Fri, 08 Apr 2022 14:40:37 -0400 Received: from mail-ed1-x544.google.com ([2a00:1450:4864:20::544]:38701) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nctX9-0004XE-5A for guix-devel@gnu.org; Fri, 08 Apr 2022 14:40:37 -0400 Received: by mail-ed1-x544.google.com with SMTP id z99so2437598ede.5 for ; Fri, 08 Apr 2022 11:40:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:subject:from:to:date:user-agent:mime-version :content-transfer-encoding; bh=M2XXIwAduhrieUa+94R5MOmWEogjEVu6pL11LUKnbZE=; b=mC/2R48gDH2Iiii0DzxCUv1BVSb6s8XigwBBpwch1qMiklVXciYKmt7mQvwBAiap9w szxGaxBZS9MJNICHg2nBKaOdJE64jHavOPery65PLlyUDScZSwPUCpoRJbiGDnNm8NRK EH+JKuCjAlO1qb3acMxI615hvpw3Bk0RowdGWp0koG7fNU6FemcZFG6Smrj7mF417/vT hgPiARP3IRJVMn8Wbyh+coRlzZnNDZoQ7MF03HzaFxDawdlCo/Ngc06BGipZ2OT+dqDB ragGaaewZoWGxoSpBWffnIkz0wfYwkzdsXID2IVdUce0OjWglmcW7ox9IsWCfLL84BEi HMjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:subject:from:to:date:user-agent :mime-version:content-transfer-encoding; bh=M2XXIwAduhrieUa+94R5MOmWEogjEVu6pL11LUKnbZE=; b=UOdueb/JQApHIoKnoPAmEGWe5ywhRFhbCxaH5hlrXnOI6SSCm0JmCmOmU6ZkUf77WX z5LHOaiteYLhabR2MVYnd8MS2TiCKb9zPnlS6I4FaqVqW5ila6Vfxtrjs/oTnIRY1QFp gz0toDNyIw/r61K8wXc6GoovzqkyQVD5B8M1NM1Wum0MMucITGJTQsvnFStCw82r29vj MkPrhjtF4MB6aLEapjrHejiiQ/HjMeCdwib9Gx6vw2VmvO4kG1iPE1FzHmGHGmf6qlys iI+O8Wo06Y8hiouX/t4XLU35dxTMhdWChrGkTYl++YIRANy8y3YkdO0TueB3jWrpFD+N hCOA== X-Gm-Message-State: AOAM533FFF+QLoyVW+cPMSls8NUaiwHYI/oy9qYW9S2l6l5vn4Pn/v16 xK+KemEXm/CX+ebH/834ecMhpDxldDU= X-Google-Smtp-Source: ABdhPJx1VruM/0ye0XAMP5NYnZV0waA5fNVfFVI8d6MEbBLj2HhazrZhMTO3ee0qs4wtjbs/hz2WvA== X-Received: by 2002:a05:6402:492:b0:404:c4bf:8b7e with SMTP id k18-20020a056402049200b00404c4bf8b7emr20382399edv.318.1649443232653; Fri, 08 Apr 2022 11:40:32 -0700 (PDT) Received: from nijino.fritz.box (85-127-52-93.dsl.dynamic.surfer.at. [85.127.52.93]) by smtp.gmail.com with ESMTPSA id f13-20020a50bf0d000000b0041cdd9c9147sm5661744edk.40.2022.04.08.11.40.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Apr 2022 11:40:32 -0700 (PDT) Message-ID: <8de0693f22bf19263406b448f587f6b0eb0195a0.camel@gmail.com> Subject: Sockets in Shepherd, and Emacs, oh my! From: Liliana Marie Prikler To: guix-devel@gnu.org Date: Fri, 08 Apr 2022 20:40:30 +0200 Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.42.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2a00:1450:4864:20::544; envelope-from=liliana.prikler@gmail.com; helo=mail-ed1-x544.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1649443264; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=M2XXIwAduhrieUa+94R5MOmWEogjEVu6pL11LUKnbZE=; b=fNFAIkKd0C4jGKRhEtwIW9xVhXrEdmWDInRpAXyM3hD1/7Azo+vhQGxopRIOOLTD0OFzvm 5YpGCdNjvOIxVX0WYdsbs2PDsIUxDnTxWdjC46588AlihpyOR4T6Fb82t+glwM2TDVAD19 ioZcjQl5EXmT88h9eyMW+9lkrU8d3dGTd9la7i7qVZMysUH0zn70b4MMedEoI0fb+3plHK q+nda27mQXTlL8dj871FpREnYyjaESjMY1bgkcwjDRs9Tysm8NOOEghTV4C7m9juHV285A m7Gv+6TKRbMU1kmp2Z65xWjp3kOIL09ZvD1WnRkxhF1dVNUHR28aftuZvqkkVA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1649443264; a=rsa-sha256; cv=none; b=Bz1hRMLm2oOO5hs5BDevZpBihIEX/7ib8Zfh/fHHyEK95b88FHvpWVHKqrqlSLrW/Ddf+4 ZuCYJosBDQdPklex/sH3H6MvV0CQPqEQT0wRsBzAOXrt81shGYEK4V28jOk9lJlurCgy40 PTjru7MziWUSdhYeK1+IDZRaiQazeuEi+v8mHuwQcQ5pdX2sFMB0ULU31xQhTpX1MAShg0 bsBzieg72PQc9sdki02ZFPhZ/SLVKSXgcDREnoNFJZKyFrRgnukCA4HX7yJDqN5Zunt0lx JPrNDw/VD8v8StR0pa9RRsyRVrDJuGGSHI8OXFNqy3s6GEHlSFDMEk/ADTwDmA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="mC/2R48g"; dmarc=pass (policy=none) header.from=gmail.com; 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: -2.57 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="mC/2R48g"; dmarc=pass (policy=none) header.from=gmail.com; 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: DAE633C973 X-Spam-Score: -2.57 X-Migadu-Scanner: scn1.migadu.com X-TUID: KWRYkJmYBw3N Hi Guix, given that Shepherd 0.9.0 adds support for systemd-style socket activation and Emacs supports that (if linked against systemd!) I wanted to try it out. Here's my "generic" recipe for constructing an Emacs service: --8<---------------cut here---------------start------------->8--- (define* (emacs #:key (name 'server) (uid (getuid)) (gid (getgid))) (make #:provides (list (symbol-append 'emacs@ name)) #:requires '() #:start (make-systemd-constructor (list "emacs" "--fg-daemon") (list (endpoint (make-socket-address AF_UNIX (format #f "/run/user/~d/emacs/~s" uid name)) #:socket-owner uid #:socket-group gid))) #:stop (make-systemd-destructor))) --8<---------------cut here---------------end--------------->8--- Note how this allows the creation of multiple sockets, that launch Emacsen on demand. For instance, I could hook up one Emacs to git changelogs, one mail reading and one to writing prose without them interfering with each other. (This assumes that tools spawing Emacs will correctly launch emacsclient, of course.) If for some reason, I am not writing that many changelogs one day, the git one doesn't need to be spawned, and so on, and so forth. Sadly, this doesn't work as intended currently. You will have to use a specially prepared emacs, that links against systemd (logind works fine too, use the recipe below). I plan to upstream these changes soon™, given that we're also lagging behind on Emacs 28. --8<---------------cut here---------------start------------->8--- (define emacs-with-systemd (package (inherit emacs) (arguments (substitute-keyword-arguments (package-arguments emacs) ((#:phases phases) #~(modify-phases #$phases (add-after 'unpack 'enable-logind (lambda _ (substitute* (list "configure.ac") (("libsystemd") "libelogind")) (delete-file "configure"))))))) (inputs (modify-inputs (package-inputs emacs) (prepend elogind))) (native-inputs (modify-inputs (package-native-inputs emacs) (prepend autoconf))))) --8<---------------cut here---------------end--------------->8--- There appear to be some bugs, though. If shepherd launches a process via systemd-constructor and it dies before claiming the socket, it will become a zombie. Further, if the process dies after having claimed the socket, shepherd will not reset service's entry points and running value. Both should be fixable in my opinion. So, what's for the future? If someone wants to do so, they could adapt my shepherd service for Guix Home. It'd be very nice to one day be able to spawn an Emacs service fine-tuned to desired editing purposes. Think of using `guix shell --container' building packages that you'd otherwise rarely need on demand, for example. With that in mind, happy hacking!