Message ID | 9556afd9d860c28ea5abe15fd42d8e2989e5244c.1718510232.git.richard@freakingpenguin.com |
---|---|
State | New |
Headers |
Return-Path: <guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org> X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id D96FE27BBE9; Sun, 16 Jun 2024 04:59:27 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 1658B27BBE2 for <patchwork@mira.cbaines.net>; Sun, 16 Jun 2024 04:59:25 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from <guix-patches-bounces@gnu.org>) id 1sIh2m-0004up-BT; Sat, 15 Jun 2024 23:59:04 -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 <Debian-debbugs@debbugs.gnu.org>) id 1sIh2k-0004uX-H8 for guix-patches@gnu.org; Sat, 15 Jun 2024 23:59:02 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1sIh2k-0004rY-9F for guix-patches@gnu.org; Sat, 15 Jun 2024 23:59:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1sIh2k-0003fy-C0 for guix-patches@gnu.org; Sat, 15 Jun 2024 23:59:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#71586] [PATCH] services: web: Improve nginx formatting for extra-content Resent-From: Richard Sent <richard@freakingpenguin.com> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces@debbugs.gnu.org> Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 16 Jun 2024 03:59:02 +0000 Resent-Message-ID: <handler.71586.B.171851032814087@debbugs.gnu.org> Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 71586 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 71586@debbugs.gnu.org Cc: Richard Sent <richard@freakingpenguin.com> X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.171851032814087 (code B ref -1); Sun, 16 Jun 2024 03:59:02 +0000 Received: (at submit) by debbugs.gnu.org; 16 Jun 2024 03:58:48 +0000 Received: from localhost ([127.0.0.1]:47335 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces@debbugs.gnu.org>) id 1sIh2V-0003f8-9v for submit@debbugs.gnu.org; Sat, 15 Jun 2024 23:58:47 -0400 Received: from lists.gnu.org ([209.51.188.17]:56508) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <richard@freakingpenguin.com>) id 1sIh2T-0003ew-OI for submit@debbugs.gnu.org; Sat, 15 Jun 2024 23:58:46 -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 <richard@freakingpenguin.com>) id 1sIh2S-0004sN-8x for guix-patches@gnu.org; Sat, 15 Jun 2024 23:58:44 -0400 Received: from mail-108-mta114.mxroute.com ([136.175.108.114]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <richard@freakingpenguin.com>) id 1sIh2Q-0004ql-Mu for guix-patches@gnu.org; Sat, 15 Jun 2024 23:58:44 -0400 Received: from filter006.mxroute.com ([136.175.111.3] filter006.mxroute.com) (Authenticated sender: mN4UYu2MZsgR) by mail-108-mta114.mxroute.com (ZoneMTA) with ESMTPSA id 1901f326ad900017a3.001 for <guix-patches@gnu.org> (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Sun, 16 Jun 2024 03:58:36 +0000 X-Zone-Loop: 78efd3c53ad4f806480fb3a1793e28fa3eb639d70e67 X-Originating-IP: [136.175.111.3] DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=freakingpenguin.com; s=x; h=Content-Transfer-Encoding:MIME-Version: Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=AkMdTTgEwpAb3Kgd6Us9jBm7QxzvrbcitY5lCjkVkqI=; b=GM7Oburvzi2v1K9/f8KOFPj97j 1eD5evZ5m5jy5a4rndpiGdC5wOfdn5PucBIJ20JhHZ58m6+mv0qm2wa4Pc02n8ff1GyeHdCfih9mP zhCMLyQ8Wzk3s/6Pa1ahvXNIP91vadc0CSgsRVs+ivVaijQ6AH3tUGecc0LI9JFVQVDsgZlEtrL4y YSWWOB6Wb35wWtTZc4pVtKSE2ppOpCNPMzzAiZlGt5TfP8ZV1//oXSdELNE5D2l/o901Bj32/JE3w XxFnjySotXxwjWOYmhajq9wRfhNW+KnN+9PNKfwWLzjDKpa8v5T2VHwetSipG08rFZYBQCNxw91Vh qs8Tjb1A==; From: Richard Sent <richard@freakingpenguin.com> Date: Sat, 15 Jun 2024 23:57:12 -0400 Message-ID: <9556afd9d860c28ea5abe15fd42d8e2989e5244c.1718510232.git.richard@freakingpenguin.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Authenticated-Id: richard@freakingpenguin.com Received-SPF: pass client-ip=136.175.108.114; envelope-from=richard@freakingpenguin.com; helo=mail-108-mta114.mxroute.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: <guix-patches.gnu.org> List-Unsubscribe: <https://lists.gnu.org/mailman/options/guix-patches>, <mailto:guix-patches-request@gnu.org?subject=unsubscribe> List-Archive: <https://lists.gnu.org/archive/html/guix-patches> List-Post: <mailto:guix-patches@gnu.org> List-Help: <mailto:guix-patches-request@gnu.org?subject=help> List-Subscribe: <https://lists.gnu.org/mailman/listinfo/guix-patches>, <mailto:guix-patches-request@gnu.org?subject=subscribe> Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches |
Series |
[bug#71586] services: web: Improve nginx formatting for extra-content
|
|
Commit Message
Richard Sent
June 16, 2024, 3:57 a.m. UTC
* gnu/services/web (default-nginx-config): When extra-content is a list, add 4 space indentation and a newline to every line. If it's a string, continue inserting it directly. This makes the list serialization behavior more consistent with other services. Change-Id: Iec8614ba3cfc37292a566197e8d39b352b04846a --- gnu/services/web.scm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) base-commit: 612e4dd98f7d1d015e405af9d029bede3fe3c280
Comments
Hello, On 2024-06-15 23:57:12 -0400, Richard Sent wrote: > * gnu/services/web (default-nginx-config): When extra-content is a list, add 4 > space indentation and a newline to every line. If it's a string, continue > inserting it directly. This makes the list serialization behavior more > consistent with other services. > > Change-Id: Iec8614ba3cfc37292a566197e8d39b352b04846a > --- > gnu/services/web.scm | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/gnu/services/web.scm b/gnu/services/web.scm > index 406117c457..094b1e4b45 100644 > --- a/gnu/services/web.scm > +++ b/gnu/services/web.scm > @@ -771,7 +771,12 @@ (define (default-nginx-config config) > "\n" > (map emit-nginx-upstream-config upstream-blocks) > (map emit-nginx-server-config server-blocks) > - extra-content > + (match extra-content > + ((? string? extra-content) extra-content) > + ((? list? extra-content) > + (map (lambda (line) > + (simple-format #f " ~A\n" line)) The format here sadly prevents producing `include' directives with link to the store, since any file-like object will be just serialized as its representation: `("foo" "bar" ("aa" "bb") ,(plain-file "foo" "baz")) Will end up as: foo bar (aa bb) #<<plain-file> name: "foo" content: "baz" references: ()> Neither the list nor the plain-file are as expected. What about doing just this: (match extra-content ((? string? extra-content) extra-content) ((? list? extra-content) (map (lambda (line) `(" " ,line "\n")) extra-content))) This produces the expected (in my opinion) output: foo bar aabb /gnu/store/7pz4iczjvgvn9ikpp1ip50bk6vi4sk7b-foo Meaning you can now do things like (extra-content `(("include " ,%some-file.conf ";"))) And it will work as expected. It already works like this for raw-content in the nginx-server-configuration. Thoughts? > + extra-content))) > "\n}\n")))) > > (define %nginx-accounts > > base-commit: 612e4dd98f7d1d015e405af9d029bede3fe3c280 > -- > 2.45.1 > > Have a nice day, Tomas Volf -- There are only two hard things in Computer Science: cache invalidation, naming things and off-by-one errors.
diff --git a/gnu/services/web.scm b/gnu/services/web.scm index 406117c457..094b1e4b45 100644 --- a/gnu/services/web.scm +++ b/gnu/services/web.scm @@ -771,7 +771,12 @@ (define (default-nginx-config config) "\n" (map emit-nginx-upstream-config upstream-blocks) (map emit-nginx-server-config server-blocks) - extra-content + (match extra-content + ((? string? extra-content) extra-content) + ((? list? extra-content) + (map (lambda (line) + (simple-format #f " ~A\n" line)) + extra-content))) "\n}\n")))) (define %nginx-accounts