From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id 0DSPG3S0Y2XWfgAAauVa8A:P1 (envelope-from ) for ; Sun, 26 Nov 2023 22:11:16 +0100 Received: from aspmx1.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id 0DSPG3S0Y2XWfgAAauVa8A (envelope-from ) for ; Sun, 26 Nov 2023 22:11:16 +0100 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 A91CB17C5D for ; Sun, 26 Nov 2023 22:11:15 +0100 (CET) Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=rdklein.fr header.s=zoho header.b=hngvpoDT; arc=pass ("zohomail.eu:s=zohoarc:i=1"); 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"; dmarc=none ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1701033076; 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=BBdWvQM3MCeT+cEVZrkuPywdJppRn+pc3R9RGF65L+o=; b=YAEVgr1OISLIP1K8GVBNgn5x6xWmJCDGyG5IVNekLTVoUZ6/28dQaGNlpOpZJken6OFQ7m dZrWlVOpWJCmg7OLmmJ3WW8S8DVpwO6MI3EKmMCU2HQDYfmyZ5WBDI6Yz3mMvajpLOjXD6 UbMjvlOT/Ms9jRx9dLLRNtfMxXD017eQtx9JSLecOL+QtDLNN8PsDIJP37GMhOB+3Isnpz IXZ/IrSj0XvjAE6WnSUqP+gdwVt5j4OS9/0u9MsCbpx3EbBqMrZ/Qj1IWFHHygaodszzBO IYr6ZnRIwVf+9yso9zZB5O4YSxwk4HVsPV7BzF//IteES++E85rM5lOpxNrKfg== ARC-Authentication-Results: i=2; aspmx1.migadu.com; dkim=pass header.d=rdklein.fr header.s=zoho header.b=hngvpoDT; arc=pass ("zohomail.eu:s=zohoarc:i=1"); 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"; dmarc=none ARC-Seal: i=2; s=key1; d=yhetil.org; t=1701033076; a=rsa-sha256; cv=pass; b=QwXi1ElO2BuO3swZXXjojDjunVIud8Wz6PiSnyJf9/5b/LzmHfzBmxyUcbtwD4Qdh0z9CE eaGs5trXi8+8ojE8IFnXzRja40Wn6TLHg8zVnL5CBRoAj3hX2GrMOWSIyhiLNhvD1pBN3e HM5MdPR1BJ9IvQPpDabj0+VaNb7i5moHkdmOyg4w8jEKWrTzm4WXZ5gWw8Q2tT9jB0mDMK hZ7vrdzF5bEjttxF67D3rflhahwkvI/GJSLvMMG+h50v7dPeRIEeZz3LuMUcv96TuOaJYw E/MSE56zRVc86WUTqrXxTbRkoi7Iio5vER8w6NQyImqNzWeygeXP54gqP28qZA== Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r7MOt-00052a-NX; Sun, 26 Nov 2023 16:10:47 -0500 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 1r7MOs-00051k-1v for guix-devel@gnu.org; Sun, 26 Nov 2023 16:10:46 -0500 Received: from sender11-op-o11.zoho.eu ([31.186.226.225]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r7MOp-0003k6-5F; Sun, 26 Nov 2023 16:10:45 -0500 ARC-Seal: i=1; a=rsa-sha256; t=1701033037; cv=none; d=zohomail.eu; s=zohoarc; b=ixx/c/8H+fgyB4uWgsAd2HYq/vhAp6smJsjBoToowYbZHADtgBhoPGoBVdJPF7/rTI7tiUSfTpV2v72NCmLmcsn0rf7d3Vpo0jDfyo7VQXRh4UBWcxWlZfz1J6RgVI8LjKQCoiV9LJTLUhCBAlGdP4CPC54l0iMEQAqR5q1PR3E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.eu; s=zohoarc; t=1701033037; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=BBdWvQM3MCeT+cEVZrkuPywdJppRn+pc3R9RGF65L+o=; b=d60jFlqhj35R+vRMG6K1Gk6Ssqzzk4pmIBcfeEQR9U8xTH5joPUGTFvDLIvBBKAk5bCpWC+ZP6pe4tLRIIfNCqYpuJ79KINZTBsEilKJCZHRSeBqFLQdh+pyfscFVsRPCNnnVgSThLgZHovF+lJefgMMFgsDfHckEPaPNjsVRmA= ARC-Authentication-Results: i=1; mx.zohomail.eu; dkim=pass header.i=rdklein.fr; spf=pass smtp.mailfrom=edou@rdklein.fr; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1701033037; s=zoho; d=rdklein.fr; i=edou@rdklein.fr; h=References:From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:In-reply-to:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-Id:Reply-To; bh=BBdWvQM3MCeT+cEVZrkuPywdJppRn+pc3R9RGF65L+o=; b=hngvpoDTdK4D9eTCML+ycou/dJ2/daGknyBUqO5dyNFJoTpOa4tTia83mA2Z8BOV rX/cvOT2aavw3V98Q4GDTfZ3Y3MQMpPgOsI1NmJexFkqtChO45xcu4o3ok8b+nSnkFW rebHVW8LMmyZessc+K54htlkUIJSNp3EGvGY+5EjR9+k0UbqJLgQiBrm6V/IRCvv6Ai CaGOJ41b0Uaowf+/3ZmJ/YtfZb+ed+FXeEpjoztchv/ma1MgSJyKRgR5cSwsVW/OyMR RUjL54mjWwzlSV3GleraHhhvMdAZP5r9h4z9Sg/U7YuK9wDGEdUaQdVex9Wf62ZpiCh w8dFoOC08A== Received: from schwarzy (lfbn-idf3-1-667-244.w86-252.abo.wanadoo.fr [86.252.237.244]) by mx.zoho.eu with SMTPS id 1701033034107300.6969101297759; Sun, 26 Nov 2023 22:10:34 +0100 (CET) References: <87wn377rst.fsf@rdklein.fr> <877cm6reum.fsf@rdklein.fr> <52c2337b277721108e5e7cdd6ea32e37e3c20628.camel@gmail.com> <8734wsqwrh.fsf@rdklein.fr> <33976deaf13ce785edefa6ac1b3610054dd4a031.camel@gmail.com> User-agent: mu4e 1.10.2; emacs 28.2 From: Edouard Klein To: Liliana Marie Prikler Cc: Attila Lendvai , guix-devel@gnu.org, Ludovic =?utf-8?Q?Court=C3=A8s?= , Josselin Poiret Subject: Re: Syntactic Diabetes (was Re: A friendlier API for operating-system declarations) Date: Sun, 26 Nov 2023 21:46:19 +0100 In-reply-to: <33976deaf13ce785edefa6ac1b3610054dd4a031.camel@gmail.com> Message-ID: <87v89op6f2.fsf@rdklein.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External Received-SPF: pass client-ip=31.186.226.225; envelope-from=edou@rdklein.fr; helo=sender11-op-o11.zoho.eu X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.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, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=-1, RCVD_IN_MSPIKE_WL=-0.01, 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-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Spam-Score: -4.32 X-Spam-Score: -4.32 X-Migadu-Queue-Id: A91CB17C5D X-Migadu-Scanner: mx12.migadu.com X-TUID: naNW20Z/KwCu Liliana Marie Prikler writes: >> =C2=A0=C2=A0=C2=A0 (instantiate nginx) > I do wish you spelled out service. Also, instantiate takes as much > characters to type as add-service. > Done, see below. I was worried about the paronymy between add-service and add-services which already exists. I defer to you and your experience on this, naming things is hard. >> To see the value of this syntactic sugar, try to replicate this MWE >> with the standard syntax. It's not horrendous, but it *is* off- >> putting to many newcomers to git, whereas this sugary piece is more >> readable for them (sample size of 1, p=3D0.00000005). > Well, that'd be > ... I tried: (let ((base (minimal-ovh "osef"))) (operating-system (inherit base) (services (cons* (service nginx-service-type) (service mumble-server-service-type (mumble-server-configuration (welcome-text "couocu") (port 64738))) (service openssh-service-type (openssh-configuration (password-authentication? #f) (allow-empty-passwords? #t) (authorized-keys `(("alice" ,(local-file "/home/edouard/.s= sh/id_rsa.pub")))))) (operating-system-user-services base))))) I admit that this is as readable as the sweet version, but: - Openssh is already defined in (minimal-ovh "osef"), so the build fails with: 'guix system: error: service 'ssh-daemon' provided more than once' - you forgot the removal of guix-service, which admitedly is not used much= in practice anyway The problem with those two is that they break the nice structure of just adding services, and now one has to first remove an element from (operating-system-user-services base), then edit one of the element of the resulting list, then add to elements to it. It is probably possible to write it in a readable way, maybe less so than the sweet version, but not so much as to justify adding the new macros to guix. However the readability is not the main selling point, the writeability is. Please do not discount how hard it is to write that kind of stuff when scheme's not your main language. It is possible people here forgot how hard this is for beginners, especially those like me whose brain is deformed from years using algol-derived syntaxes. I think we are losing a lot of mindshare because of the hard step of learning both guile and guix, and the kind of syntactic sugar I suggest may help bridge the gap long enough for newcomers to ease into the syntax, after they get a taste of guix' capabilities. Another experiment: with the sweet syntax, you can easily extend services, without having to define a -record-type, etc. Just define a function. I can write more at length about that if you want. > On that note, we also have extend-openssh-authorized-keys for the use > with modify-services. > I see it now in the source, but I was unaware of its existence. Thanks for the swift again review :) Cheers, Edouard. -------------mwe.scm (use-modules (beaver system) (beaver functional-services) (gnu packages version-control) (gnu services web) (gnu services telephony) (gnu services ssh) (gnu services base) (guix gexp)) (-> (minimal-ovh "osef") (add-service nginx) (add-service mumble-server (welcome-text "coucou") (port 64738)) (extend-service openssh `(("alice" ,(local-file "/home/edouard/.ssh/id_= rsa.pub")))) (modify-service openssh (password-authentication? #f) (allow-empty-passwords? #t)) (remove-service guix)) ----------------------functional-services.scm (define-module (beaver functional-services) #:use-module (gnu system) #:use-module (gnu services) #:export (add-service extend-service modify-service remove-service)) (define syntax->string (compose symbol->string syntax->datum)) (define (service-configuration stx service) "Return the syntax one can use to refer to xxx-configuration for the given service" (datum->syntax stx (string->symbol (string-append (syntax->string service) "-configuration")))) (define (service-type stx service) "Return the syntax one can use to refer to xxx-service-type for the given service" (datum->syntax stx (string->symbol (string-append (syntax->string service) "-service-type")))) (define-syntax add-service (lambda (stx) (syntax-case stx () [(_ os service-name) (with-syntax ([service-type (service-type stx #'service-name)]) #'(begin ((lambda (x) ;; It is wrapped in a lamba to make sure os is ;; evaluated once only. It it wasn't in a labmda, whatever ;; form os is in the calling code would be repeated ;; multiple times, and so if the form was e.g. (some-func ;; os), then some-func would be called multiple times, ;; which may not be desirable. (operating-system (inherit x) (services (cons (service service-type) (operating-system-user-services x))))) os)))] [(_ os service-name forms ...) (with-syntax ([service-type (service-type stx #'service-name)] [service-configuration (service-configuration stx #'service-name)]) #'(begin ((lambda (x) ;; Wrapping in a lambda for the same reasons as a= bove (operating-system (inherit x) (services (cons (service service-type (service-configuration forms ...)) (operating-system-user-services x))))) os)))]))) (define-syntax extend-service (lambda (stx) (syntax-case stx () [(_ os service-name forms ...) (with-syntax ([service-type (service-type stx #'service-name)]) #'(begin ((lambda (x) (operating-system (inherit x) (services (cons (simple-service (format #f "A ~a extension" (syntax->st= ring #'service-name)) service-type forms ...) (operating-system-user-services x))))) os)))]))) (define-syntax modify-service (lambda (stx) (syntax-case stx () [(_ os service-name forms ...) (with-syntax ([service-type (service-type stx #'service-name)] [service-configuration (service-configuration stx #'service-name)]) #'(begin ((lambda (x) (operating-system (inherit x) (services (modify-services (operating-system-user-services x) (service-type config =3D> (service-configuration (inherit config) forms ...)))))) os)))]))) (define-syntax remove-service (lambda (stx) (syntax-case stx () [(_ os service-name forms ...) (with-syntax ([service-type (service-type stx #'service-name)]) #'(begin ((lambda (x) (operating-system (inherit x) (services (modify-services (operating-system-user-services x) (delete service-type))))) os)))])))