From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id CNyrM/coYWVriAAAG6o9tA:P1 (envelope-from ) for ; Fri, 24 Nov 2023 23:51:36 +0100 Received: from aspmx1.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id CNyrM/coYWVriAAAG6o9tA (envelope-from ) for ; Fri, 24 Nov 2023 23:51:35 +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 7F89353495 for ; Fri, 24 Nov 2023 23:51:35 +0100 (CET) Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=YAFTkjXZ; 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" ARC-Seal: i=1; s=key1; d=yhetil.org; t=1700866295; a=rsa-sha256; cv=none; b=AJPJdwk2e+RskRdvGoDl1JFyZGYySBuapXh6Eh32F/R/zjiiEvDMO9chzMlFpZvVLZcssO mVeRXEV6RAzINI/0pF/2mfKOMeYH6pBw8Jwn98r59QSlV55kq/iBFeYJr59kDgZa7q8N1K wlvw+wxoWllxAIFezmrKJ7/KCq5J7zjRsZz8qcjkNpH+EDMgk8rHX8eO22Ul/WQwm0BSVB S5p+3tao5pMAdqP7KbDW3OFIkBscgOtFc88crgIDmeKhPZ/yhmHit63ZSmFCtIwEBmyUm/ Stc5zB54zLL5f5GHDUketiVEPXMJCBThyym0ULlArl2BYMslUYNMoJ0fzETwXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1700866295; 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=Sj19G/NZU9njQNTdsUEZMt5cQpijEnKbBNM6wWBaHCQ=; b=HIpeCCVuGdpwShuZBm5ZcxfRUlTrML5erTbiZ8tcjdTDb5e+yclY07BwMD1U/0dieV/pXV Cu624012wB7WEP6gbJ7yZlg0AM0F24AURswLr+qNy37HcgRSLpQBuf+vEEj1g63NfaTc8l fon/mrlu7K3eCjjjZe3JomMb9P0u8bno4XdyceNw+lJWR27LU7ds6u8o5bwaq5YLOcdLYM SR0RpM8957qtS4hTJhvZoskN3xpvmF3Br1tmWBM7P+gmuMgYF84TbufqNfuRgpiJbD3ToX VC7Ol/QO6DevcXvn2bSDoCeYhxtFzpSZiYJo+VWklFMOdhNNcprhy69jGxS9ug== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=YAFTkjXZ; 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" Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r6f0k-0003YV-S0; Fri, 24 Nov 2023 17:50:58 -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 1r6f0i-0003YC-Kr for guix-devel@gnu.org; Fri, 24 Nov 2023 17:50:56 -0500 Received: from mail-lj1-x232.google.com ([2a00:1450:4864:20::232]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r6f0g-0004Ib-Ca; Fri, 24 Nov 2023 17:50:56 -0500 Received: by mail-lj1-x232.google.com with SMTP id 38308e7fff4ca-2c876e44157so29480361fa.2; Fri, 24 Nov 2023 14:50:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700866251; x=1701471051; darn=gnu.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:from:to:cc:subject :date:message-id:reply-to; bh=Sj19G/NZU9njQNTdsUEZMt5cQpijEnKbBNM6wWBaHCQ=; b=YAFTkjXZBgwWOxLYfWu2DnvqOxmtgH8DyJx5ZF6xbidq7E077hIiqFr9ZHjx89oE1M sr/duTxsMedEBKRdleX1cqxwHiNor+JAYQj//Rsi/QVORnDPGdX62H+XHNECYhM8andm ONHIOqgMnou2PWI690Jicz7rRy94Heg7HjYVb23Qr1YAUAZENJ3/7z9LNjcY/EoQRnBa YCPA0yWq6S0qW5448aFP9nZtcRtGgnUhJPksLxtRlTNRJVZXgMvW1TIZIRjNDVwTsx9y Xb4UBMjIvHBCvmO9hB7PeY9SXq8k79UIonCPAsdWDsmbw3kT0XE243fnltEt0pDUjEze zcfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700866251; x=1701471051; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=Sj19G/NZU9njQNTdsUEZMt5cQpijEnKbBNM6wWBaHCQ=; b=Zc1lXTiDYLs5MR34eUWWESFBnVU9yEc/u34rvqQ2NNUjX3gqAq1AbRlF/aRqm1awuc uqru95KeTC+Qn/GBpk+o8EBYt3UJ8GntZrIwqkg3rNG48571w//CtajdpPMq3e/iT0u4 22iMslGhtQpCCwcTEgQhap88nq4CLhSHGDX5fOWHgu1C4ARt0vrUoT2JfVHuxtGdwmk1 DvxbUp072ggKzwpre5suj99b/m72N/tDjcrhootnypXHvxcf4NaBsPPv5+W/yVxpCCjh UXQwSjF7IqShmi1pBPBVQ84b+5BDQ7N7YX/rYrd6ri4XJIrHnMZAMPszJ8Oi2MxN5jZ5 bx4g== X-Gm-Message-State: AOJu0Yz83iwesXUrqzDWFgCB8NuYamLOpGlPBCYBKBQTCdk6KgWVBrFt HSXrnOLAxb3KhMM14E8Zdgv4E+ozr98= X-Google-Smtp-Source: AGHT+IGXGy3ia4gAj2HJE5Vpe6UwaTFNuUkHowVeh27wvC8m6tg5ldvYDzzwldNHuueYGWeytvX+Vw== X-Received: by 2002:a19:4310:0:b0:503:17fd:76bb with SMTP id q16-20020a194310000000b0050317fd76bbmr2366998lfa.39.1700866251024; Fri, 24 Nov 2023 14:50:51 -0800 (PST) Received: from lumine.fritz.box (85-127-52-93.dsl.dynamic.surfer.at. [85.127.52.93]) by smtp.gmail.com with ESMTPSA id u11-20020aa7db8b000000b00543525d9fddsm2215987edt.21.2023.11.24.14.50.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Nov 2023 14:50:50 -0800 (PST) Message-ID: <52c2337b277721108e5e7cdd6ea32e37e3c20628.camel@gmail.com> Subject: Re: Syntactic Diabetes (was Re: A friendlier API for operating-system declarations) From: Liliana Marie Prikler To: Edouard Klein , guix-devel@gnu.org Cc: Ludovic =?ISO-8859-1?Q?Court=E8s?= , Josselin Poiret Date: Fri, 24 Nov 2023 23:50:49 +0100 In-Reply-To: <877cm6reum.fsf@rdklein.fr> References: <87wn377rst.fsf@rdklein.fr> <877cm6reum.fsf@rdklein.fr> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.46.4 MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::232; envelope-from=liliana.prikler@gmail.com; helo=mail-lj1-x232.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-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Scanner: mx11.migadu.com X-Spam-Score: -9.43 X-Migadu-Queue-Id: 7F89353495 X-Migadu-Spam-Score: -9.43 X-TUID: EtyGB46gUcVp Am Freitag, dem 24.11.2023 um 22:43 +0100 schrieb Edouard Klein: > Dear Guixers, >=20 > Here is a quick status update on my proposition to expose composable > functions to change operating-system declarations. >=20 > Thank you all for the feedback you gave me :) It's very nice to not > be talking in the void. >=20 > After Liliana opined that these functions should not put too much > burden on the maintainers, a position with which I wholeheartedly > agree, here is what I came up with: >=20 > https://gitlab.com/edouardklein/guix/-/blob/beaverlabs/beaver/functional-= services.scm >=20 > (file copied at the end of this email to make the list self-content > instead of relying on external services) >=20 > That's a macro-writing macro called "define-os-macros-for" that, for > any service (for example nginx), defines five forms. They all > evaluate to a modified os: >=20 > (.nginx os)=C2=A0 ;; Add nginx in its default configuration > (.nginx os toto titi tutu... )=C2=A0 ;; Add nginx, with toto... given as > arguments to nginx-configuration > (+nginx os toto titi tutu...)=C2=A0 ;; Extend an existing nginx service, > giving > toto... as arguments to simple-service > (~nginx os toto...)=C2=A0 ;; Edit an existing nginx service, passing > toto... as > arguments to modify-service > (-nginx os)=C2=A0 ;; Removes nginx >=20 > You can see all of them used in: > https://gitlab.com/edouardklein/guix/-/blob/beaverlabs/beaver/system.scm?= ref_type=3Dheads >=20 > e.g. the mkdir-p function is a (+activation ...), > all web server functions use (+nginx...), > mumble is (.mumble... ), > os/git uses (~openssh... ). >=20 > I've use (-foo) forms while testing, but not in production. The > others are currently running in prod on guix-hosting.com and the- > dam.org. The naming is a little confusing and imho not clearly helpful. For example, why (.nginx os) instead of=C2=A0the triple (service+ OS SERVICE [CONF]) (service- OS SERVICE) (modify-service OS SERVICE UPDATE) Of course, you could also define triples (add-SERVICE OS [CONF]),=20 (remove-SERVICE OS) and (modify-SERVICE OS UPDATE), which would fall in line with the macro approach, but keep names a little more readable.=20 (If you want to use your names, you can rename them in #:use-modules). > -----------------functional-services.scm---------------- > (define-module (beaver functional-services) > =C2=A0=C2=A0 #:use-module (gnu system) > =C2=A0=C2=A0 #:export (*-append)) >=20 > (define (syntax->string s) > =C2=A0 "Shorthand to convert a piece of syntax to a string" > =C2=A0 (symbol->string (syntax->datum s))) Or (compose symbol->string syntax->datum). > (define (*->string s) > =C2=A0 "Convert into a string any symbol-like type we may encounter in a > macro" > =C2=A0 (cond > =C2=A0=C2=A0 [(string? s) s] > =C2=A0=C2=A0 [(symbol? s) (symbol->string s)] > =C2=A0=C2=A0 [else (syntax->string s)]))=C2=A0 ;; assume syntax There should not be a need to define this. Try to use exact types. > (define* (*-append #:rest args) > =C2=A0 "Return a symbol which is a concatenation of the given symbol-like > args" > =C2=A0 (string->symbol (apply string-append (map *->string args)))) As above. > (define-syntax define-os-macros-for > =C2=A0 ;; This macro, called like e.g. (define-os-macros-for foo) will > define four > =C2=A0 ;; forms, .foo, +foo, ~foo and -foo > =C2=A0 ;; > =C2=A0 ;; These forms take an operating-system as their first argument, > and > =C2=A0 ;; evaluate to an operating-system, which allows one to compose > them > =C2=A0 ;; (e.g. (foo (bar os))). > =C2=A0 (lambda (x) > =C2=A0=C2=A0=C2=A0 (syntax-case x () > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 [(_ foo) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (with-syntax > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ([dot-foo=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (datum->syntax x (*-append "." #'fo= o))] > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 [plus-foo=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (datum->syntax x (*-append "+" #'fo= o))] > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 [tilde-foo=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (datum->syntax x (*-append "~" #'foo))= ] > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 [minus-foo=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (datum->syntax x (*-append "-" #'foo))= ] > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 [foo-service-type=C2=A0 = (datum->syntax x (*-append #'foo "- > service-type"))] > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 [foo-configuration (datu= m->syntax x (*-append #'foo "- > configuration"))]) You're repeating datum->syntax here a bit too much for my liking. This patch is also missing the most important part of beaverlabs to make this work: the -> threading macro. Cheers