From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id 0IeDM3h7Y2UDMAEAG6o9tA:P1 (envelope-from ) for ; Sun, 26 Nov 2023 18:08:09 +0100 Received: from aspmx1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id 0IeDM3h7Y2UDMAEAG6o9tA (envelope-from ) for ; Sun, 26 Nov 2023 18:08:08 +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 A92125C8B3 for ; Sun, 26 Nov 2023 18:08:08 +0100 (CET) Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=rdklein.fr header.s=zoho header.b=ciJKCaVO; arc=pass ("zohomail.eu:s=zohoarc:i=1"); dmarc=none; 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=2; s=key1; d=yhetil.org; t=1701018488; a=rsa-sha256; cv=pass; b=Whl9cDn88iSZ97mFuMhE/VNU8OWMiM8nn+z1pbA4VZQIflH0xKkEcsCyLToE1MCS2jTpiC O0aYOALnKSyZPecYE1yKXVcDSUEiWMc4M8QJO27Ts5A7IxHBREJRoHD15mZwcQwGTwG7IP FEO7w0ek1JHBeIUHh6nPIgS1YohSzylp8Gtw19FVNjYwcfDLG54alm1pjqFCaK/yOnFIUS ES1aoZNECBkHKPi7RcYL0xxL5Om5un98zs7ja/mJA/lqRFc75pnNeH6AJy43JOIaPFqMqn EgylPRF7MDol8CUMdWal0Qf9RPVAw1BL0/6A8CMS3L2L/tJFsTppWtgU2yaixQ== ARC-Authentication-Results: i=2; aspmx1.migadu.com; dkim=pass header.d=rdklein.fr header.s=zoho header.b=ciJKCaVO; arc=pass ("zohomail.eu:s=zohoarc:i=1"); dmarc=none; 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=2; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1701018488; 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=UGV5fHGZzwDstMPvelJAefGHoXbMqtUQSLnGC91XVno=; b=Mo65Tq9OOCPsUK8vuiu1KtVCTgcuT7FflzcfpbKmHfs0uqlMGHI58Y27B6qZD6EivzsEFR gozarNIJVFtNYO21CZH6vr+sybfnDI2VkhmuQ4aaBH6Yl3p8PvL4vTjqaMPQNWRD6rAEGE CXXrAHH5VOrR06EwNJT1BIQdM9e7GEsWjh8i1aKly2DuOLmPDji2aMWjAMcWEPa7jrVquC IYkWyqo3049epXFJIOnfSiFGdso/UGiZ8Y0g76100PowJeoKr6qtS4EgF+ydXcxqmrBfAt afOftmhl2ahkEAePNFBtrjkSgc/bSsWZpb5JdI4EHjYD6gT1xso84UxxIvK2og== Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r7IQk-0000ix-2D; Sun, 26 Nov 2023 11:56:26 -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 1r7IQj-0000il-0R for guix-devel@gnu.org; Sun, 26 Nov 2023 11:56:25 -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 1r7IQg-0004dl-79; Sun, 26 Nov 2023 11:56:24 -0500 ARC-Seal: i=1; a=rsa-sha256; t=1701017774; cv=none; d=zohomail.eu; s=zohoarc; b=dXMnNvAVjbLIDCREO+zz2On7dVcWxmMoRR2BbJ6NU74Nx6sS/iuon+OtYMm0b3l+7suVfObLrh2HFHPsUSkiHDbBEw7GehzsGTcZ6bobqPsS6ahhqqBgyMoreHP6tfn2ogIKQ9RVqSZradnCwNPOio1CglFe1R8Ot2FqWByfSsw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.eu; s=zohoarc; t=1701017774; 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=UGV5fHGZzwDstMPvelJAefGHoXbMqtUQSLnGC91XVno=; b=dCFXtkWQcyPBQNpD54r3+3qHNUgPrFLKR+VoRUvaEvKuwzL8LYvioSmLW8i4Zff2szQCLnUffaxLcOW9ny4VtVSu+l0d9rAtSdxlvPDz68Wl9j0fTaNqbt8sp+0/0mCz7VnjmnyZnIlkxbTVcOuwQhvh0/kKRA7cGd8I9eSXNAQ= 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=1701017774; 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=UGV5fHGZzwDstMPvelJAefGHoXbMqtUQSLnGC91XVno=; b=ciJKCaVOGz4GrZAXNVr7ZKzWfPBdM2/ICESRqleajjaceqPSyuFDTtgGAdnEmL1v rTTB3ENW1dL/8LP0RW/Z5Hdgddi88a8ygwcUQBvqxLID6miPu0buKXRuaR/axDfy4h5 +nR4ic2g1lAmykyTzC9MBy2rUCKyXg4M1JJryzsV6dOZRVSwVhiX0qOyiFW+Z+VeX1n dhK7Aj9LJ+5DU3V9XVj6idZZpNPD6N4hrr+D/X2f351d+5w4QtM9IzcbKXNYtv8FMlj IGeVSOFhz33C+XjV1CQy6N/EDJ6BoBNGk3X2r+4jiylO1/czWVfDN5L2ODW4n04nGrr K0e7VdJnjA== Received: from schwarzy (lfbn-idf3-1-667-244.w86-252.abo.wanadoo.fr [86.252.237.244]) by mx.zoho.eu with SMTPS id 1701017771072269.8907433126951; Sun, 26 Nov 2023 17:56:11 +0100 (CET) References: <87wn377rst.fsf@rdklein.fr> <877cm6reum.fsf@rdklein.fr> <52c2337b277721108e5e7cdd6ea32e37e3c20628.camel@gmail.com> User-agent: mu4e 1.10.2; emacs 28.2 From: Edouard Klein To: Attila Lendvai Cc: Liliana Marie Prikler , 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 17:49:42 +0100 In-reply-to: Message-ID: <8734wsqwrh.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-Country: US X-Migadu-Flow: FLOW_IN X-Migadu-Scanner: mx13.migadu.com X-Migadu-Spam-Score: -4.32 X-Spam-Score: -4.32 X-Migadu-Queue-Id: A92125C8B3 X-TUID: QGBarFJp4vdv Thank you Liliana and Attila for the swift and actionable feedback :) Below is a revised proposition. Here is a minimal working example of an os declaration: ------------------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") (instantiate nginx) (instantiate mumble-server (welcome-text "coucou") (port 64738)) (extend openssh `(("alice" ,(local-file "/home/edouard/.ssh/id_rsa.pub"= )))) (modify openssh (password-authentication? #f) (allow-empty-passwords? #t)) (remove guix)) ------------------------------------------------------- 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). Here is the revised functional-services.scm, not yet commited and pushed, and only lightly tested in local containers, but not in production: Advice and comments welcome :) ------------functional-services.scm-------------- (define-module (beaver functional-services) #:use-module (gnu system) #:use-module (gnu services) #:export (instantiate extend modify remove)) (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 instantiate (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 (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 (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 (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)))]))) ------------------------- Attila Lendvai writes: >> (service+ OS SERVICE [CONF]) >> (service- OS SERVICE) >> (modify-service OS SERVICE UPDATE) > > > what would the benefit of generating multiple macros for each service com= pared to the above functional API (with 3-4 elements altogether)? > > i could be missing something here, but it seems to be precious little to = me while it costs some extra complexity. > > if i were to add a syntactic abstraction for this, i'd generate a full DS= L in the form of a (modify-operating-system OS [fictional DSL to describe d= esired changes]). > > but i don't think the extra complexity justifies any macrology here. > > -- > =E2=80=A2 attila lendvai > =E2=80=A2 PGP: 963F 5D5F 45C7 DFCD 0A39