From patchwork Fri May 23 09:04:32 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Trofimov X-Patchwork-Id: 42881 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 05B9E27BC4A; Fri, 23 May 2025 10:05:30 +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=-7.4 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2, RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE, 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 C3C1B27BC49 for ; Fri, 23 May 2025 10:05:27 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uIOKw-0007jf-1W; Fri, 23 May 2025 05:05:06 -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 ) id 1uIOKt-0007iz-Gt for guix-patches@gnu.org; Fri, 23 May 2025 05:05:04 -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 ) id 1uIOKt-0000rW-7u for guix-patches@gnu.org; Fri, 23 May 2025 05:05:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:From:To:In-Reply-To:References:Subject; bh=8B07q27+a2yMB6svj1avgti2IiU89lrs9J415WqMbzU=; b=MDYgh+58IaFI1WCjNtCPXAQaraxbA8c60wYhlZ39C6vihZaXGmuwaEaD47GKMvzzWJZsSQjgmb2iXl+ZZ+VOL4VVqezVMW/BaCZYIJV4Iuxd4RjouyHuAYbgIpyU1AOPv6VIrUxipRt6rCODp8hZaGTiJxWX5miYhDnDL5IhVaGfufB5aVa7noQTK5ElGxwzlSNBzEphuQPRlPURfvmqSDN7QRBsoUMjqPT1TFhCEarqDw4XJ0wLiVcU0Cum6wbGyJKYZBEyScMqWyY/9bi24ICJKfhrnUY42Mi1M+QmEeSqyu3Rgos7kRtwrxQCG+lO6Sx1OZI3mwnCEx4MzzwFow==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1uIOKs-0006iv-OR; Fri, 23 May 2025 05:05:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#78546] [PATCH 1/3] services: configuration: Add define-enumerated-field-type helper. References: In-Reply-To: Resent-From: Sergey Trofimov Original-Sender: "Debbugs-submit" Resent-CC: sarg@sarg.org.ru, guix-patches@gnu.org Resent-Date: Fri, 23 May 2025 09:05:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 78546 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 78546@debbugs.gnu.org Cc: Sergey Trofimov , Sergey Trofimov X-Debbugs-Original-Xcc: Sergey Trofimov Received: via spool by 78546-submit@debbugs.gnu.org id=B78546.174799109425803 (code B ref 78546); Fri, 23 May 2025 09:05:02 +0000 Received: (at 78546) by debbugs.gnu.org; 23 May 2025 09:04:54 +0000 Received: from localhost ([127.0.0.1]:45522 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uIOKj-0006i1-Hg for submit@debbugs.gnu.org; Fri, 23 May 2025 05:04:54 -0400 Received: from mail-ej1-x635.google.com ([2a00:1450:4864:20::635]:42229) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1uIOKg-0006hJ-1n for 78546@debbugs.gnu.org; Fri, 23 May 2025 05:04:51 -0400 Received: by mail-ej1-x635.google.com with SMTP id a640c23a62f3a-ad1f6aa2f84so149267266b.0 for <78546@debbugs.gnu.org>; Fri, 23 May 2025 02:04:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sarg.org.ru; s=google; t=1747991082; x=1748595882; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=8B07q27+a2yMB6svj1avgti2IiU89lrs9J415WqMbzU=; b=Nfw4TP2U7nvfSN1NzMcJwZwbQlDIZkLyIgvRLrwwPSdt9966xw4zkcts4JfZKo0q2J 0GRnuoii9ySZlG3gUvUkqCPNR11QtYPDeDAB9ir+Fv6QfsW8CCsK+rPML5V9nMmiBYq1 nmJFMDJOknHjG6nZj0i+QRAy4xZGGw64O975fLkjBVOfDUv0QeNuQVa9KsJ52yro2XBp J+tFoTr7wQPT8C6GgSiWaCeAfG4Pb882lGQCc6NCGxlvc33TveJ4lwtZCA3GqVj1gu2M MFhVoQilyfme02nupGR+L7HAccNawXSJkf/eK5Aqhjnpv8THDpgRSk3gNrI2Moydj13j /u+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747991082; x=1748595882; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=8B07q27+a2yMB6svj1avgti2IiU89lrs9J415WqMbzU=; b=UkDSllziAsg2VGa7cVNgf5S0tvr+vBsoWEWwUg7GyPiZMik1odogKuzEfpwOX7NHP9 Jjw59ny1lLiwbr3iJvyhFoIscIeAM5EjSOl8pZovmXess6dOPu6+ZGaq4AAuhRF9g9QI 6w4Xgnuw4bjXNXB7/7TnoOU9TW9cPognlg8j2QX1SWZoqP2BS2pXHfL1Dxd//8JMpm80 1W+MUOSPY2HhHBRAUPfJtb6rtC9RP7m+wbq6ELiMkt1wI2mlbNsYlGMooMV/zoV98igs WdEaJsIysXO/fbyklFqLvrgxQ4/ATp4jHPR2Hz557yNPmOSTMfBE1Zrx/OtFBIFYxQQy vweQ== X-Gm-Message-State: AOJu0YzR3eGhMRW4CshONBBH5ymjA7ekz5Fwj8rvDZbpHMxv+4IZEp/Y mNC00MWTtYY5sUVW2Q/KQjySi1KdYYt2DSmOEwR4S4+Z1/t3MuiZ5LG/jNrMtwTL1XW3xEb9HVh 5Jfqw03g= X-Gm-Gg: ASbGncvP07Lr2dNTZNro4Uns21ypRr9coAZIPX03Dn3967kUkRvp1/zIgQ1xaj9Od85 c6c4LMbYP1LmIEWD67ujH5wgyf0DE8H+i/siEhsWKPq+M1uc0hXXMAnjUJSKEyAfkPZWXZ0Hnoa qxHUvUJveczYzltqiG5Gx2pGTzW6sok3Zg/EodfttNBFklVaOP+dCAja8XDd6cPN+JcOp4to7r2 f6GxBWGiFtxQW6tmJ37PRdCLzQjxsGXi+732TM3S3eYKtlNS5IwH3D9bRfl+ch3uYo+88+rS/2W iD4b+CUp8434IThPIdUMbbPW3JZ3JZRUx3O3NZiANpaIp/DcJyFlHkq0nJ8I X-Google-Smtp-Source: AGHT+IG9B29A+w5HNoTLhiySUxJDoCOEsz1FN1aePufv3RsvTksjxlfEUDwZkWfSGQUC3FlVrXwMNA== X-Received: by 2002:a17:907:3e8b:b0:ad5:112:490b with SMTP id a640c23a62f3a-ad64e7b5146mr208875966b.9.1747991081919; Fri, 23 May 2025 02:04:41 -0700 (PDT) Received: from localhost ([2a02:2454:a095:5600:a64e:31ff:fe38:fd6c]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ad52d4cc5e9sm1205895866b.173.2025.05.23.02.04.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 May 2025 02:04:41 -0700 (PDT) From: Sergey Trofimov Date: Fri, 23 May 2025 11:04:32 +0200 Message-ID: X-Mailer: git-send-email 2.49.0 MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-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 * gnu/services/cups.scm (define-enumerated-field-type): Move... * gnu/services/configuration.scm (define-enumerated-field-type): ...here. * gnu/services/vpn.scm (define-enumerated-field-type): Remove. * gnu/services/power.scm (define-enum): Replace with define-enumerated-field-type. Change-Id: I89ec40f479e3f800268e714f1f88d638be017c7e --- gnu/services/configuration.scm | 14 +++++++++++ gnu/services/cups.scm | 12 --------- gnu/services/power.scm | 45 +++++++++++----------------------- gnu/services/vpn.scm | 12 --------- 4 files changed, 28 insertions(+), 55 deletions(-) base-commit: 60025c2425dbac99df1219ed907c7c55e454b932 diff --git a/gnu/services/configuration.scm b/gnu/services/configuration.scm index 15eddd7665..6d9fd1feae 100644 --- a/gnu/services/configuration.scm +++ b/gnu/services/configuration.scm @@ -75,6 +75,7 @@ (define-module (gnu services configuration) configuration->documentation empty-serializer serialize-package + define-enumerated-field-type filter-configuration-fields @@ -508,6 +509,19 @@ (define* (interpose ls #:optional (delimiter "\n") (grammar 'infix)) (cons delimiter acc)))) '() ls)) +(define-syntax define-enumerated-field-type + (lambda (x) + (syntax-case x (prefix) + ((_ name (option ...) (prefix serializer-prefix)) + #`(begin + (define (#,(id #'name #'name #'?) x) + (memq x '(option ...))) + (define (#,(id #'name #'serializer-prefix #'serialize- #'name) field-name val) + (#,(id #'name #'serializer-prefix #'serialize-field) field-name val)))) + + ((_ name (option ...)) + #`(define-enumerated-field-type name (option ...) (prefix #{}#)))))) + ;;; ;;; Commonly used predicates diff --git a/gnu/services/cups.scm b/gnu/services/cups.scm index 738bb7f5cc..27aac7a16a 100644 --- a/gnu/services/cups.scm +++ b/gnu/services/cups.scm @@ -137,18 +137,6 @@ (define (non-negative-integer? val) (define (serialize-non-negative-integer field-name val) (serialize-field field-name val)) -(define-syntax define-enumerated-field-type - (lambda (x) - (define (id-append ctx . parts) - (datum->syntax ctx (apply symbol-append (map syntax->datum parts)))) - (syntax-case x () - ((_ name (option ...)) - #`(begin - (define (#,(id-append #'name #'name #'?) x) - (memq x '(option ...))) - (define (#,(id-append #'name #'serialize- #'name) field-name val) - (serialize-field field-name val))))))) - (define-enumerated-field-type access-log-level (config actions all)) (define-enumerated-field-type browse-local-protocols diff --git a/gnu/services/power.scm b/gnu/services/power.scm index ec8ae555d4..ad386549cd 100644 --- a/gnu/services/power.scm +++ b/gnu/services/power.scm @@ -204,23 +204,6 @@ (define-configuration/no-serialization apcupsd-event-handlers #~(#t)) "The handler for the battattach event.")) -(define-syntax define-enum - (lambda (x) - (syntax-case x () - ((_ name values) - (let* ((datum/name (syntax->datum #'name)) - (datum/predicate (string->symbol - (format #f "enum-~a?" datum/name))) - (datum/serialize (string->symbol - (format #f "serialize-enum-~a" datum/name)))) - (with-syntax - ((predicate (datum->syntax x datum/predicate)) - (serialize (datum->syntax x datum/serialize))) - #'(begin - (define (predicate value) - (memq value values)) - (define serialize serialize-symbol)))))))) - (define mangle-field-name (match-lambda ('name "UPSNAME") @@ -252,25 +235,25 @@ (define mangle-field-name ('data-time "DATATIME") ('facility "FACILITY"))) -(define (serialize-string field-name value) +(define (serialize-field field-name value) #~(format #f "~a ~a\n" #$(mangle-field-name field-name) '#$value)) -(define serialize-symbol serialize-string) -(define serialize-integer serialize-string) +(define serialize-string serialize-field) +(define serialize-symbol serialize-field) +(define serialize-integer serialize-field) (define (serialize-boolean field-name value) - #~(format #f "~a ~a\n" - #$(mangle-field-name field-name) - #$(if value "on" "off"))) + (serialize-field field-name (if value "on" "off"))) (define-maybe string) -(define-enum cable '( simple smart ether usb - 940-0119A 940-0127A 940-0128A 940-0020B 940-0020C - 940-0023A 940-0024B 940-0024C 940-1524C 940-0024G - 940-0095A 940-0095B 940-0095C 940-0625A MAM-04-02-2000)) -(define-enum type '(apcsmart usb net snmp netsnmp dumb pcnet modbus test)) -(define-enum no-logon '(disable timeout percent minutes always)) -(define-enum class '(standalone shareslave sharemaster)) -(define-enum mode '(disable share)) +(define-enumerated-field-type enum-cable + ( simple smart ether usb + 940-0119A 940-0127A 940-0128A 940-0020B 940-0020C + 940-0023A 940-0024B 940-0024C 940-1524C 940-0024G + 940-0095A 940-0095B 940-0095C 940-0625A MAM-04-02-2000)) +(define-enumerated-field-type enum-type (apcsmart usb net snmp netsnmp dumb pcnet modbus test)) +(define-enumerated-field-type enum-no-logon (disable timeout percent minutes always)) +(define-enumerated-field-type enum-class (standalone shareslave sharemaster)) +(define-enumerated-field-type enum-mode (disable share)) (define-configuration apcupsd-configuration (apcupsd (package apcupsd) "The @code{apcupsd} package to use.") diff --git a/gnu/services/vpn.scm b/gnu/services/vpn.scm index f97cbac7bb..56022ac27a 100644 --- a/gnu/services/vpn.scm +++ b/gnu/services/vpn.scm @@ -141,18 +141,6 @@ (define (ip-mask? val) #f))) (define serialize-ip-mask serialize-string) -(define-syntax define-enumerated-field-type - (lambda (x) - (define (id-append ctx . parts) - (datum->syntax ctx (apply symbol-append (map syntax->datum parts)))) - (syntax-case x () - ((_ name (option ...)) - #`(begin - (define (#,(id-append #'name #'name #'?) x) - (memq x '(option ...))) - (define (#,(id-append #'name #'serialize- #'name) field-name val) - (serialize-field field-name val))))))) - (define-enumerated-field-type proto (udp tcp udp6 tcp6)) (define-enumerated-field-type dev From patchwork Fri May 23 09:04:33 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Trofimov X-Patchwork-Id: 42880 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 88A5227BC4C; Fri, 23 May 2025 10:05:29 +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=-7.4 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2, RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE, 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 E87F327BC4D for ; Fri, 23 May 2025 10:05:27 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uIOKz-0007kE-ED; Fri, 23 May 2025 05:05:09 -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 ) id 1uIOKx-0007jl-FV for guix-patches@gnu.org; Fri, 23 May 2025 05:05:07 -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 ) id 1uIOKw-0000xh-EQ; Fri, 23 May 2025 05:05:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:Date:From:To:Subject; bh=5Funi3tuZKoaYxgLo+kP2aQUe/2aPhnrBGoCo/as63Y=; b=h+w7mKX9W/tj0Bge6xsekkSIHExarjRSbiNkFaCADrqInIHS+gXq+U2wy96KMIxVernccqxEMw+6iXTJseSQ3loxLjqJgEiWfxXspwTVf0syKfDJuND4Dc81NpefmZCHzVPvc1m81JGxKy37s52bBCHJ/wIXLVml5nqWNe9BMpGjv6wswMcL6dmIBcCQUri/NsHulmEDaf+MpD27Ag/3FvnnLhmPa1I3ypSGsGy4eRWL744fsTQxLl1nCZrNCD/IRaICmNwg//c5DoefTOMYENANCYI48cyOcZ+qw7ML3eKK7Ung5Cl8ganwtMg/x+ziOWKmxF8NMkx3SGLFQcVwiw==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1uIOKt-0006j6-Aw; Fri, 23 May 2025 05:05:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#78546] [PATCH 2/3] services: networking: Add shepherd-requirement for dhcpcd. Resent-From: Sergey Trofimov Original-Sender: "Debbugs-submit" Resent-CC: sarg@sarg.org.ru, gabriel@erlikon.ch, ludo@gnu.org, maxim.cournoyer@gmail.com, guix-patches@gnu.org Resent-Date: Fri, 23 May 2025 09:05:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 78546 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 78546@debbugs.gnu.org Cc: Sergey Trofimov , Sergey Trofimov , Gabriel Wicki , Ludovic =?utf-8?q?Court=C3=A8s?= , Maxim Cournoyer X-Debbugs-Original-Xcc: Sergey Trofimov , Gabriel Wicki , Ludovic =?utf-8?q?Court=C3=A8s?= , Maxim Cournoyer Received: via spool by 78546-submit@debbugs.gnu.org id=B78546.174799109525820 (code B ref 78546); Fri, 23 May 2025 09:05:03 +0000 Received: (at 78546) by debbugs.gnu.org; 23 May 2025 09:04:55 +0000 Received: from localhost ([127.0.0.1]:45524 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uIOKk-0006i7-Et for submit@debbugs.gnu.org; Fri, 23 May 2025 05:04:55 -0400 Received: from mail-ed1-x533.google.com ([2a00:1450:4864:20::533]:44181) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1uIOKg-0006hM-LZ for 78546@debbugs.gnu.org; Fri, 23 May 2025 05:04:51 -0400 Received: by mail-ed1-x533.google.com with SMTP id 4fb4d7f45d1cf-60119cd50b6so11893644a12.0 for <78546@debbugs.gnu.org>; Fri, 23 May 2025 02:04:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sarg.org.ru; s=google; t=1747991084; x=1748595884; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5Funi3tuZKoaYxgLo+kP2aQUe/2aPhnrBGoCo/as63Y=; b=Gmxg+QskL0aoY/UOaXXpPooEykos7OMABblH4GlUDMqFoGxwfu3y7S1j2UtYjcuE9x HrAO8LvXVevf6tBVnKij/ac8i6boftWwk3AzsIAmxXq7t8XazRm4sVK9mG/sIQ72LVJo IN+Fh6lj0Z+V6q8DD3Nq2kkpQ1ztXUiVn7cxYlr1p/zx5sbwC7mMvESbtoIYaz8PMhvd c8TnTsaRCqNkvlxgLnX7cCuyEJyEbyJTCVGqgFa6P3yMarsAP0Ur/qgO2uDj3/dpWEAJ wQ0UxCn3wZtVx5GGi4xRmFfB14qdDi6GSuRjlhdauQflq6Z7XHZiepyU8sqNbf6pyU26 XHJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747991084; x=1748595884; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5Funi3tuZKoaYxgLo+kP2aQUe/2aPhnrBGoCo/as63Y=; b=qPrIG78GPjZy9xR9BmNM3PubAQfTTE8It+iz11JbmHUPC9PueyxQvkCS/Ik4NxAE0+ cd8lFwounH04qNFrKMdnoyfZ/1W4FieaGvvXVgzxfsxy9FBGNKzeNcZ8ObTEZLoAeuBD 2iMKIW/NPOEY+nSjnMrpLAiQAAX92pW1anZdmLEE+tbJzVvJWqLxFA68kdO1CW4FQq86 2vmvRgIOntCXEjiNVi470daFmrYpEvIpXG4hh1JCnc7CRs0ahdjF6G4VdEQ+gH6eTqbg YimGHTWjbof4Z7VvnOKSMmT3jTbTnIz9Rva1Nu23ZT/Haq0z3jR+v0JiL3MO91u/ysYS lIRQ== X-Gm-Message-State: AOJu0YwoBedrySTNiU43zQExfVyPM+I1BHNnOj3su5hrLH5HohfDhSaZ xWmxlOnIXFp+njWUmpyiYb0IajpMxVIeIuFjDmI2VtGUFMkPSKDhfWdm27m086t48M2tugj7eHg pAirDdk0= X-Gm-Gg: ASbGncuF3N5rhFeh381AIJdtvtz6MFBH1ds3317mAIGG8g3MxIXHssJXvNgATRod4Ad nnRJ4F7Gkv+aggZIhzxD+96/DhmI/Ixv0P5tZuPCQn08ctdP4LmQrX3Dmb07wLlGz/0JgBZxIC5 T8hmjcfYznmm3PKhH8sBE8spPeWENFYO5O25ykqjPg0HFLV96A3dmg/yOZGm0N+NqVM0ewCHBvm xklwPsz/YJLegFyJ2NX3K6zxRhtjSyI32aPdDJwXahxNm3LD6IrqN2eszMVDQWNULZFKyPbgxGQ QRYANtOZKddaCWRqcu6eHstMNMvWVK37Ms/8sDZPawo/hD/vAQ== X-Google-Smtp-Source: AGHT+IHjUzzKqoWpGztqbQDamXSPdC+RWUuyfv6UkJcZEXCcs+kDJDrIVwneHtE2kZiqYdTHxuNkGA== X-Received: by 2002:a05:6402:2108:b0:5fa:b131:f009 with SMTP id 4fb4d7f45d1cf-6007e825a98mr24623684a12.0.1747991084036; Fri, 23 May 2025 02:04:44 -0700 (PDT) Received: from localhost ([2a02:2454:a095:5600:a64e:31ff:fe38:fd6c]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-6005ae3b824sm11675844a12.79.2025.05.23.02.04.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 May 2025 02:04:43 -0700 (PDT) From: Sergey Trofimov Date: Fri, 23 May 2025 11:04:33 +0200 Message-ID: X-Mailer: git-send-email 2.49.0 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-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 * gnu/services/networking.scm (dhcpcd-configuration): Add shepherd-requirement field. (dhcpcd-shepherd-service): Use it. * doc/guix.texi (Networking Setup): Regenerate dhcpcd-configuration documentation. (File Systems): Fix typo. Change-Id: Id347e2bed2569237685a47be82dbf686640db25b --- doc/guix.texi | 17 +++++++++++------ gnu/services/networking.scm | 31 +++++++++++++++++++------------ 2 files changed, 30 insertions(+), 18 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 02f472246a..3ef2e50e57 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -18332,7 +18332,7 @@ File Systems might not be sufficient as @code{networking} being marked as started does @emph{not} imply the network has already been configured and in working order (for example, when using -@code{dhcpcd-client-service-type}). For such cases, adding a +@code{dhcp-client-service-type}). For such cases, adding a requirement on a custom @code{network-online} service may be necessary. A sample @code{network-online} one-shot Shepherd service implementation is provided below: @@ -21980,12 +21980,13 @@ Networking Setup @item @code{duid} (default: @code{""}) (type: maybe-string) DHCPv4 clients require a unique client identifier, this option uses the DHCPv6 Unique Identifier as a DHCPv4 client identifier as well. For -more information, refer to @uref{https://www.rfc-editor.org/rfc/rfc4361, RFC 4361} -and @code{dhcpcd.conf(5)}. +more information, refer to +@uref{https://www.rfc-editor.org/rfc/rfc4361,RFC 4361} and +@code{dhcpcd.conf(5)}. @item @code{persistent?} (default: @code{#t}) (type: boolean) -When true, automatically de-configure the interface when @command{dhcpcd} -exits. +When true, automatically de-configure the interface when +@command{dhcpcd} exits. @item @code{option} (default: @code{("rapid_commit" "domain_name_servers" "domain_name" "domain_search" "host_name" "classless_static_routes" "interface_mtu")}) (type: list-of-strings) List of options to request from the server. @@ -22019,9 +22020,13 @@ Networking Setup @item @code{extra-content} (type: maybe-string) Extra content to append to the configuration as-is. +@item @code{shepherd-requirement} (default: @code{()}) (type: list-of-symbols) +This is a list of symbols naming Shepherd services that this service +will depend on. + @end table -@end deftp +@end deftp @cindex NetworkManager diff --git a/gnu/services/networking.scm b/gnu/services/networking.scm index 67653e2cbf..4cb7313808 100644 --- a/gnu/services/networking.scm +++ b/gnu/services/networking.scm @@ -126,6 +126,7 @@ (define-module (gnu services networking) dhcpcd-configuration-vendor-class-id dhcpcd-configuration-client-id dhcpcd-configuration-extra-content + dhcpcd-configuration-shepherd-requirement ntp-configuration ntp-configuration? @@ -609,6 +610,12 @@ (define-configuration dhcpcd-configuration maybe-string "Extra content to append to the configuration as-is.") + (shepherd-requirement + (list-of-symbols '()) + "This is a list of symbols naming Shepherd services that this service +will depend on." + empty-serializer) + (prefix dhcpcd-)) (define (dhcpcd-config-file config) @@ -628,19 +635,19 @@ (define dhcpcd-account-service (shell (file-append shadow "/sbin/nologin"))))) (define (dhcpcd-shepherd-service config) - (let* ((config-file (dhcpcd-config-file config)) - (command-args (dhcpcd-configuration-command-arguments config)) - (ifaces (dhcpcd-configuration-interfaces config))) - (list (shepherd-service - (documentation "dhcpcd daemon.") - (provision '(networking)) - (requirement '(user-processes udev)) - (actions (list (shepherd-configuration-action config-file))) - (start + (match-record config + (command-arguments interfaces shepherd-requirement) + (let ((config-file (dhcpcd-config-file config))) + (list (shepherd-service + (documentation "dhcpcd daemon.") + (provision '(networking)) + (requirement `(user-processes udev ,@shepherd-requirement)) + (actions (list (shepherd-configuration-action config-file))) + (start #~(make-forkexec-constructor - (list (string-append #$dhcpcd "/sbin/dhcpcd") - #$@command-args "-B" "-f" #$config-file #$@ifaces))) - (stop #~(make-kill-destructor)))))) + (list (string-append #$dhcpcd "/sbin/dhcpcd") + #$@command-arguments "-B" "-f" #$config-file #$@interfaces))) + (stop #~(make-kill-destructor))))))) (define dhcpcd-service-type (service-type (name 'dhcpcd) From patchwork Fri May 23 09:04:34 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Trofimov X-Patchwork-Id: 42882 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 5CAE827BC4C; Fri, 23 May 2025 10:06:21 +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=-7.4 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2, RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE, SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham 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 94FEC27BC49 for ; Fri, 23 May 2025 10:06:20 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uIOM2-0008Ig-Ut; Fri, 23 May 2025 05:06:14 -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 ) id 1uIOLv-0008HR-3E for guix-patches@gnu.org; Fri, 23 May 2025 05:06:07 -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 ) id 1uIOLs-0001IC-Ur; Fri, 23 May 2025 05:06:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:Date:From:To:Subject; bh=VsLEuU+wl0gD/5DF4++hXvms4px+AwasLFn9bwHggU8=; b=ffcg9cDaB0ETngz14iSEN8tyCIFSTi34dF0JhNiLPXansnKBCpOWcoGKnCs9RrIhKvVwdkF/llqOQAp5qS0nSaobsW5JcPsj+UdpkqR15mvUedgQ/Hh+cV78U7+WWMSaKLYUhJhpjZGYnlLEuZEfRX3Ea/9xrbg9uvfYpvlXIan7E1UfElR+lcXoF7NeA/mNQpK64IdOTopqwBM98kE79YqEisy+VcHp9Wdb1KpvTkJZLR2pU8w8XLngTD7BXJZaic41ThyjtXEVsTH3nRt59Hbm5tfQvlO9cszaGLp1on6CAg32Bt547A/EODJ2oTNGH5LWgo7qEMtxSL9YDn114A==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1uIOLq-0006sh-V6; Fri, 23 May 2025 05:06:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#78546] [PATCH 3/3] services: networking: Add iwd-service-type. Resent-From: Sergey Trofimov Original-Sender: "Debbugs-submit" Resent-CC: sarg@sarg.org.ru, gabriel@erlikon.ch, ludo@gnu.org, maxim.cournoyer@gmail.com, guix-patches@gnu.org Resent-Date: Fri, 23 May 2025 09:06:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 78546 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 78546@debbugs.gnu.org Cc: Sergey Trofimov , Sergey Trofimov , Gabriel Wicki , Ludovic =?utf-8?q?Court=C3=A8s?= , Maxim Cournoyer X-Debbugs-Original-Xcc: Sergey Trofimov , Gabriel Wicki , Ludovic =?utf-8?q?Court=C3=A8s?= , Maxim Cournoyer Received: via spool by 78546-submit@debbugs.gnu.org id=B78546.174799110425886 (code B ref 78546); Fri, 23 May 2025 09:06:02 +0000 Received: (at 78546) by debbugs.gnu.org; 23 May 2025 09:05:04 +0000 Received: from localhost ([127.0.0.1]:45526 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uIOKs-0006iy-QR for submit@debbugs.gnu.org; Fri, 23 May 2025 05:05:04 -0400 Received: from mail-ed1-x52b.google.com ([2a00:1450:4864:20::52b]:47517) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1uIOKj-0006hP-87 for 78546@debbugs.gnu.org; Fri, 23 May 2025 05:04:55 -0400 Received: by mail-ed1-x52b.google.com with SMTP id 4fb4d7f45d1cf-5fff52493e0so10631420a12.3 for <78546@debbugs.gnu.org>; Fri, 23 May 2025 02:04:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sarg.org.ru; s=google; t=1747991087; x=1748595887; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=VsLEuU+wl0gD/5DF4++hXvms4px+AwasLFn9bwHggU8=; b=vqgM39bwfU0wkNEVRipRbZRZ7HhNrD01Q9bmV31Dhtxll9giMtj4Na5sVCaabehaeu Vc/dSkvKeFFZkQs8oapHRJsi05iDkUQ/tHpdm6kvZ3x8jtVl9MloeVEY9D7V2bFe8h0Q 4suYy29wB0Kt4NOopCUrHtSgIwYMmdB5SB+Smwm1W7DM9FYBEtcsp1iBVIwHW8DeWadG xfmfMM+A1LvaJtHypvYZ+qtl+DLzZQFZG+cbQFuvRmLroCk4TAC8Guz3QLuN6VJ2Dr7d LPQenNbQ8NuAg4LgIGaXkDsl17UaI4L4q8/FL7WAjdaChZFwk10w1ZKy6gHYqnDMqihm hv1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747991087; x=1748595887; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VsLEuU+wl0gD/5DF4++hXvms4px+AwasLFn9bwHggU8=; b=Jek5aDJg4TMlc9MRB4lga44WlscXS2a+Z7fYuhYvvvdGlNJ1HGjpaTQ1Ipf6N1nA11 HbuRA1uTbOgEfPF6VPOsfJGaWeXPv8dXdjMQ1IUn8jSJVE/8jAt4m7fqHCMd3S9AWMsx M6+LY0LuHj+gya8z5zBp2M/AW0M0oIJY9z+qSrFPFk1PKtCom/ekUPQ8FXPqL7FjfUgh oDlsVtAxXR5AlhQ8MBMO4tACs4AjpCsNob17Wo6jKY7wcFv5NezN/5vOd383bNDf5IYO yJIy8BwCc3zPhhp0Fmx/Yp5INtUiGrYsUyixvvgUVAHODPphPZqscId2V0rUhElq7wtD 8Ejg== X-Gm-Message-State: AOJu0Yw0X9U4NqDgN2ZIn95rjKCLU3d2q1BN6LmECSjAcnzM/I061OFY iKb/7yzzz1tFPdTvbrmw9HDczfeNlAnMBOxZhlbHmi/HGDq4HVfFW52lLudcNObrlULAwhJywP7 EGGlOsg8= X-Gm-Gg: ASbGncsAdnKx2I+e7qrSSJL2fo3Vsb4Ljz0o+qA6Pwwqfc9ZlxYVvTrE97uWri1GspC 7cxZnN5vHaC1Bmu/VWGcVkl3ccb4gGfGiLFh/yLSs7dNbYgmmXQeEW4Dalv3UvpSDFeHeQrgjPe SuJlCAGxrphXZ5BWk+6GF+Eprru8OfWRFpiIL3f1zvFzVBAmNQH25TPnja4PKEEHvolCecgbWVB RryIlPApgyxlrwusnudXruPz8ACKc9IcXvVAbS5E2/ayIKsSVIWp6Alskoo0Oy0Qi2Yv0oo2Ra2 GiGc4W/AqKBEbS3wfwx6OvuoRLzONwE+5tZxoNVdQ2WBuKY8EQ== X-Google-Smtp-Source: AGHT+IF+HVLS5w3LNIXYHWdwKOgiL8VsAosroG2psWGCEcynfDl01NsDPa7MNtMywtI3A0p1lMqG0w== X-Received: by 2002:a17:906:8d7:b0:ad5:372d:87e3 with SMTP id a640c23a62f3a-ad5372dbbb2mr1995084966b.27.1747991086177; Fri, 23 May 2025 02:04:46 -0700 (PDT) Received: from localhost ([2a02:2454:a095:5600:a64e:31ff:fe38:fd6c]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ad52d047cf1sm1212140366b.16.2025.05.23.02.04.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 May 2025 02:04:45 -0700 (PDT) From: Sergey Trofimov Date: Fri, 23 May 2025 11:04:34 +0200 Message-ID: <8617d132a80c6570e1c1a0ebe8d02b0baacfc9ef.1747990996.git.sarg@sarg.org.ru> X-Mailer: git-send-email 2.49.0 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-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 * gnu/services/networking.scm (iwd-service-type): New service type. (iwd-configuration), (iwd-settings), (iwd-scan-settings), (iwd-general-settings), (iwd-network-settings): New configuration types. * doc/guix.texi (Networking setup): Document it. Change-Id: I852115b9c6768b3ec4eedb34a7f9e66438bd1429 --- doc/guix.texi | 157 ++++++++++++++++++++++++ gnu/services/networking.scm | 236 ++++++++++++++++++++++++++++++++++++ 2 files changed, 393 insertions(+) diff --git a/doc/guix.texi b/doc/guix.texi index 3ef2e50e57..5c07b35ccb 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -22404,6 +22404,163 @@ Networking Setup @end table @end deftp +@cindex IWD +@defvar iwd-service-type +This is the service type to run @acronyml{IWD,Internet Wireless Daemon}, +a wireless daemon required to authenticate against encrypted WiFi +networks. +@end defvar + +@quotation Warning +By default @code{iwd} removes and re-creates interfaces it manages. It +doesn't play nicely with @code{dhcp-client-service-type} that enumerates +wireless interfaces before starting the Shepherd service. Use either +@code{dhcpcd-service-type} or the @code{iwd}'s built-in DHCP client (see +@code{enable-network-configuration} option below). +@end quotation + +@c %start of fragment + +@deftp {Data Type} iwd-configuration +Available @code{iwd-configuration} fields are: + +@table @asis +@item @code{iwd} (default: @code{iwd}) (type: file-like) +The IWD package to use. + +@item @code{interfaces} (default: @code{()}) (type: list-of-strings) +If this is set, it must specify @dfn{glob patterns} matching network +interfaces that IWD will control. + +@item @code{ignored-interfaces} (default: @code{()}) (type: list-of-strings) +If this is set, it must specify @dfn{glob patterns} matching network +interfaces that IWD will not manage. + +@item @code{phys} (default: @code{()}) (type: list-of-strings) +If this is set, it must specify @dfn{glob patterns} matching network +PHYs names that IWD will control. + +@item @code{ignored-phys} (default: @code{()}) (type: list-of-strings) +If this is set, it must specify @dfn{glob patterns} matching network +PHYs names that IWD will not manage. + +@item @code{shepherd-requirement} (default: @code{()}) (type: list-of-symbols) +Shepherd requirements the service should depend on. + +@item @code{shepherd-provision} (default: @code{(iwd)}) (type: list-of-symbols) +The name(s) of the service. + +@item @code{config} (type: iwd-settings) +Configuration settings. + +@end table + +@end deftp + + +@c %end of fragment + +@c %start of fragment + +@deftp {Data Type} iwd-settings +Available @code{iwd-settings} fields are: + +@table @asis +@item @code{general} (type: iwd-general-settings) +General settings. + +@item @code{network} (type: maybe-iwd-network-settings) +Network settings. + +@item @code{scan} (type: maybe-iwd-scan-settings) +Scan settings. + +@item @code{extra-config} (default: @code{()}) (type: list-of-strings) +Extra configuration values to append to the IWD configuration file. + +@end table + +@end deftp + + +@c %end of fragment + +@c %start of fragment + +@deftp {Data Type} iwd-general-settings +Available @code{iwd-general-settings} fields are: + +@table @asis +@item @code{enable-network-configuration} (default: @code{#f}) (type: boolean) +Setting this option to true enables @code{iwd} to configure the network +interfaces with the IP addresses. + +@item @code{extra-options} (default: @code{()}) (type: alist) +An association list of option symbols/strings to string values to be +appended to the General settings group. + +@end table + +@end deftp + + +@c %end of fragment + +@c %start of fragment + +@deftp {Data Type} iwd-network-settings +Available @code{iwd-network-settings} fields are: + +@table @asis +@item @code{enable-ipv6} (default: @code{#t}) (type: boolean) +Sets the global default that tells @code{iwd} whether it should +configure IPv6 addresses and routes + +@item @code{name-resolving-service} (default: @code{none}) (type: resolving-service) +Configures a DNS resolution method used by the system. + +@item @code{extra-options} (default: @code{()}) (type: alist) +An association list of option symbols/strings to string values to be +appended to the Network settings group. + +@end table + +@end deftp + + +@c %end of fragment + +@c %start of fragment + +@deftp {Data Type} iwd-scan-settings +Available @code{iwd-scan-settings} fields are: + +@table @asis +@item @code{disable-periodic-scan} (type: maybe-boolean) +Setting this option to @code{#t} will prevent @code{iwd} from issuing +the periodic scans for the available networks while disconnected. + +@item @code{initial-periodic-scan-interval} (type: maybe-number) +The initial periodic scan interval upon disconnect (in seconds). + +@item @code{maximum-periodic-scan-interval} (type: maybe-number) +The maximum periodic scan interval (in seconds). + +@item @code{disable-roaming-scan} (type: maybe-boolean) +Setting this option to @code{#t} will prevent @code{iwd} from trying to +scan when roaming decisions are activated. + +@item @code{extra-options} (default: @code{()}) (type: alist) +An association list of option symbols/strings to string values to be +appended to the Scan settings group. + +@end table + +@end deftp + + +@c %end of fragment + @cindex ModemManager Some networking devices such as modems require special care, and this is what the services below focus on. diff --git a/gnu/services/networking.scm b/gnu/services/networking.scm index 4cb7313808..86a6859a66 100644 --- a/gnu/services/networking.scm +++ b/gnu/services/networking.scm @@ -41,6 +41,7 @@ ;;; along with GNU Guix. If not, see . (define-module (gnu services networking) + #:use-module (gnu home services utils) #:use-module (gnu services) #:use-module (gnu services base) #:use-module (gnu services configuration) @@ -80,6 +81,7 @@ (define-module (gnu services networking) #:use-module (srfi srfi-9) #:use-module (srfi srfi-26) #:use-module (srfi srfi-43) + #:use-module ((ice-9 curried-definitions) #:select (define)) #:use-module (ice-9 match) #:use-module (ice-9 string-fun) #:use-module (json) @@ -233,6 +235,21 @@ (define-module (gnu services networking) wpa-supplicant-configuration-extra-options wpa-supplicant-service-type + iwd-configuration + iwd-configuration-config + iwd-configuration-ignored-interfaces + iwd-configuration-ignored-phys + iwd-configuration-interfaces + iwd-configuration-iwd + iwd-configuration-phys + iwd-configuration-shepherd-provision + iwd-configuration-shepherd-requirement + iwd-service-type + iwd-general-settings + iwd-network-settings + iwd-scan-settings + iwd-settings + hostapd-configuration hostapd-configuration? hostapd-configuration-package @@ -2083,6 +2100,225 @@ (define wpa-supplicant-service-type implements authentication, key negotiation and more for wireless networks.") (default-value (wpa-supplicant-configuration))))) + +;;; +;;; IWD +;;; +(define (iwd-uglify-field-name name) + (object->camel-case-string name 'upper)) + +(define (iwd-serialize-base field-name val) + (format #f "~a=~a\n" field-name val)) + +(define (iwd-serialize-field field-name val) + (iwd-serialize-base (iwd-uglify-field-name field-name) val)) + +(define iwd-serialize-number iwd-serialize-field) + +(define (iwd-serialize-boolean field-name value) + (iwd-serialize-field field-name (if value "true" "false"))) + +(define (iwd-serialize-alist field-name value) + (if (null? value) + "" + #~(string-append #$@(generic-serialize-alist list + iwd-serialize-base + value)))) + +(define-maybe boolean (prefix iwd-)) +(define-maybe number (prefix iwd-)) +(define-enumerated-field-type resolving-service + (none systemd resolvconf) + (prefix iwd-)) + +(define-configuration iwd-general-settings + (enable-network-configuration + (boolean #f) + "Setting this option to true enables @code{iwd} to configure the network +interfaces with the IP addresses.") + (extra-options + (alist '()) + "An association list of option symbols/strings to string values to be +appended to the General settings group.") + + (prefix iwd-)) + +(define-configuration iwd-network-settings + (enable-ipv6 + (boolean #t) + "Sets the global default that tells @code{iwd} whether it should configure +IPv6 addresses and routes") + + (name-resolving-service + (resolving-service 'none) + "Configures a DNS resolution method used by the system.") + + (extra-options + (alist '()) + "An association list of option symbols/strings to string values to be +appended to the Network settings group.") + + (prefix iwd-)) + +(define-configuration iwd-scan-settings + (disable-periodic-scan + maybe-boolean + "Setting this option to @code{#t} will prevent @code{iwd} from issuing the +periodic scans for the available networks while disconnected.") + + (initial-periodic-scan-interval + maybe-number + "The initial periodic scan interval upon disconnect (in seconds).") + + (maximum-periodic-scan-interval + maybe-number + "The maximum periodic scan interval (in seconds).") + + (disable-roaming-scan + maybe-boolean + "Setting this option to @code{#t} will prevent @code{iwd} from trying to scan +when roaming decisions are activated.") + + (extra-options + (alist '()) + "An association list of option symbols/strings to string values to be +appended to the Scan settings group.") + + (prefix iwd-)) + +(define-maybe iwd-network-settings) +(define-maybe iwd-scan-settings) + +(define ((iwd-serialize-config-section fields) name cfg) + #~(format #f "[~a]\n~a\n" + #$(string-upcase (object->string name) 0 1) + #$(serialize-configuration cfg fields))) + +(define serialize-iwd-network-settings + (iwd-serialize-config-section iwd-network-settings-fields)) + +(define serialize-iwd-scan-settings + (iwd-serialize-config-section iwd-scan-settings-fields)) + +(define serialize-iwd-general-settings + (iwd-serialize-config-section iwd-general-settings-fields)) + +(define-configuration iwd-settings + (general + (iwd-general-settings (iwd-general-settings)) + "General settings.") + + (network + maybe-iwd-network-settings + "Network settings.") + + (scan + maybe-iwd-scan-settings + "Scan settings.") + + (extra-config + (list-of-strings '()) + "Extra configuration values to append to the IWD configuration file." + (serializer (lambda (_ value) (string-join value "\n" 'suffix))))) + +(define-configuration/no-serialization iwd-configuration + (iwd + (file-like iwd) + "The IWD package to use.") + + (interfaces + (list-of-strings '()) + "If this is set, it must specify @dfn{glob patterns} matching network +interfaces that IWD will control.") + + (ignored-interfaces + (list-of-strings '()) + "If this is set, it must specify @dfn{glob patterns} matching network +interfaces that IWD will not manage.") + + (phys + (list-of-strings '()) + "If this is set, it must specify @dfn{glob patterns} matching network +PHYs names that IWD will control.") + + (ignored-phys + (list-of-strings '()) + "If this is set, it must specify @dfn{glob patterns} matching network +PHYs names that IWD will not manage.") + + (shepherd-requirement + (list-of-symbols '()) + "Shepherd requirements the service should depend on.") + + (shepherd-provision + (list-of-symbols '(iwd)) + "The name(s) of the service.") + + (config + (iwd-settings (iwd-settings)) + "Configuration settings.")) + +(define (iwd-generate-documentation) + (configuration->documentation 'iwd-configuration) + (configuration->documentation 'iwd-settings) + (configuration->documentation 'iwd-general-settings) + (configuration->documentation 'iwd-network-settings) + (configuration->documentation 'iwd-scan-settings)) + +(define (iwd-config-file config) + "Return an IWD configuration file." + (mixed-text-file "main.conf" + (serialize-configuration + (iwd-configuration-config config) + iwd-settings-fields))) + +(define (iwd-shepherd-service config) + (match-record config + (iwd interfaces ignored-interfaces + phys ignored-phys + shepherd-requirement shepherd-provision) + + (list (shepherd-service + (documentation "Run Internet Wireless Daemon") + (provision shepherd-provision) + (requirement `(user-processes dbus-system loopback ,@shepherd-requirement)) + (start #~(make-forkexec-constructor + (list (string-append #$iwd "/libexec/iwd") + "--logger=syslog" + #$@(if (null? interfaces) '() + (list (string-append "--interfaces=" + (string-join interfaces ",")))) + #$@(if (null? ignored-interfaces) '() + (list (string-append "--nointerfaces=" + (string-join ignored-interfaces ",")))) + #$@(if (null? phys) '() + (list (string-append "--phys=" + (string-join phys ",")))) + #$@(if (null? ignored-phys) '() + (list (string-append "--nophys=" + (string-join ignored-phys ","))))))) + (stop #~(make-kill-destructor)))))) + +(define (iwd-etc-service config) + `(("iwd/main.conf" ,(iwd-config-file config)))) + +(define iwd-service-type + (let ((add-iwd-package (compose list iwd-configuration-iwd))) + (service-type (name 'iwd) + (extensions + (list (service-extension shepherd-root-service-type + iwd-shepherd-service) + (service-extension etc-service-type + iwd-etc-service) + (service-extension dbus-root-service-type + add-iwd-package) + (service-extension profile-service-type + add-iwd-package))) + (default-value (iwd-configuration)) + (description + "Run @url{https://iwd.wiki.kernel.org/,Iwd}, +a network connection manager.")))) + ;;; ;;; Hostapd.