From patchwork Thu Jan 9 12:24:31 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: 45mg <45mg.writes@gmail.com> X-Patchwork-Id: 36801 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 A7E8327BBEA; Thu, 9 Jan 2025 12:26:11 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-6.6 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI, RCVD_IN_DNSWL_BLOCKED,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 67FDE27BBE2 for ; Thu, 9 Jan 2025 12:26:09 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tVrby-0003Sm-4E; Thu, 09 Jan 2025 07:26:06 -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 1tVrbv-0003S4-OB for guix-patches@gnu.org; Thu, 09 Jan 2025 07:26:03 -0500 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 1tVrbv-0000wk-Ev; Thu, 09 Jan 2025 07:26:03 -0500 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=Af0w2rz/Vax1gn/d5cOIoCrQ68IsBq72QhtbVcKloAw=; b=jXcIMc9Ss02zv7HTWES2Tgghmjzvmwp/4xHpLbWzmIs6+5XLf74qbsTV7g+v9NHtRuzrrCIoHgZlkyYo9uAOjouaDBHxNDz54Dv5Yqj9xC2wmj76dUahcyScT4+Z6FQY1/FBkU//wNc5gJlP7lUq4W6HznwFkmTHBBcw02ZxYJhWmU8N73doIp1svAW4D1mrLjZUxmEBEHPg/ykEp/0wfQhjAUtgwxBxWx4b8YOdOTsikdqvY2fIowXD26dX2mT1JOX+/4aoAVlI/u9Kyj+p4aeyzDGZuipwBZ44fIKH6TUKZRmYTI3Wi1Ibc7mFS2z+Fbgdri6R7QL2BdOkc/HpOQ==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tVrbu-0004lL-9R; Thu, 09 Jan 2025 07:26:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#75145] [PATCH v2 1/1] services: network-manager: Add extra-configuration-files field. Resent-From: 45mg <45mg.writes@gmail.com> Original-Sender: "Debbugs-submit" Resent-CC: ludo@gnu.org, maxim.cournoyer@gmail.com, guix-patches@gnu.org Resent-Date: Thu, 09 Jan 2025 12:26:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 75145 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 75145@debbugs.gnu.org Cc: guix-devel@gnu.org, 45mg <45mg.writes@gmail.com>, Ludovic =?utf-8?q?Cour?= =?utf-8?q?t=C3=A8s?= , Maxim Cournoyer X-Debbugs-Original-Xcc: Ludovic =?utf-8?q?Court=C3=A8s?= , Maxim Cournoyer Received: via spool by 75145-submit@debbugs.gnu.org id=B75145.173642551718209 (code B ref 75145); Thu, 09 Jan 2025 12:26:02 +0000 Received: (at 75145) by debbugs.gnu.org; 9 Jan 2025 12:25:17 +0000 Received: from localhost ([127.0.0.1]:50726 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tVrbB-0004jc-2c for submit@debbugs.gnu.org; Thu, 09 Jan 2025 07:25:17 -0500 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]:56428) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from <45mg.writes@gmail.com>) id 1tVrb8-0004gf-Kk for 75145@debbugs.gnu.org; Thu, 09 Jan 2025 07:25:15 -0500 Received: by mail-pl1-x643.google.com with SMTP id d9443c01a7336-2163b0c09afso12687955ad.0 for <75145@debbugs.gnu.org>; Thu, 09 Jan 2025 04:25:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736425508; x=1737030308; 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=Af0w2rz/Vax1gn/d5cOIoCrQ68IsBq72QhtbVcKloAw=; b=dL5XSwGYN1NUACrUtIcvLq1Q42Wp1NrApbGBXbwM/WdP9mRyMZfXYTqbvQKtpmxfqe n8QrPgQXHaJTMQAm9LgBwbm9EaOiYEyyzG0xCLfyzlTDIvhuVkye/WW71RSOZ/9KHwDi XykgXc2ErpYfqWOmeXDaNnp67kxGXNsRnqiHdjodj1kAFh1g6OG7ejaz3R6taBBFM/mt oqzidQXEgKGZ6W7UMeqp34ThOxeoNRENLcAEO4mV70KoA/qmukVS/NVeDLV+d9mCb5CD +Q1S1QDHBmbpFNwZBKQKb8skeUfrOWUOxZoq5pPyfbT8TwFmqh7T0Rh7Z7r8RePZ621W zS2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736425508; x=1737030308; 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=Af0w2rz/Vax1gn/d5cOIoCrQ68IsBq72QhtbVcKloAw=; b=tA2pJwC1hgNTV/fkAyO3m1rNOoiuxvHbdEJ2St0W4eJ11GCXtGKMOMZgUCBusspoAb L86Sl33C27pV2+4g4XpPFaRhSxlhsBA9+Py5zzJnAokxMCAPvV/jmCyfDnt9RYSrepHy FGiDJRbkre4i8W59DU0/FDPjeQQ7wXr00NwP4amMqdP7DYqRjfLyQIx0BcbGYLGx7aDv lt/X5nq26IYhRNVtvoKOwReSnNxwkLk132GZfOJqXVqs+afEcb+IDybSCD/K8H/mnaT8 fAH88sCl7sAzjvkt8JthiDk5WRJtLa5Ng2JnVJXqBFwa3o4QiF4RrlvsYjO8OLBr+KKS dvuw== X-Gm-Message-State: AOJu0Ywtc9zpuTr391fBazyKwSqcpj4fgXjagRt1SKEJcnFvqJnLfWvn t1xBb61RUzsOm8P4svNGL7nR6NsD/NPwEtzyTKnMCTQVBpyKDDbrotxfGH2I X-Gm-Gg: ASbGnctSMmIkNMoENuj65sStty8Of1ucNOzhO3YMjFzAyBLfaO2EW+v25wZKu3c0lzR SCFh78qNXW2lBAmwZGSebd4+wgTENZnvAGYgXHEEp+NkHM3sC1YITk+DRSmufOOri6eey1dpKga N7zQt0k7ZT8OIileiMoRqMK+v7FO1/NV1dqpExlFS/5nSCcp3YI82E9NUXmbjwZRemGJy5OGUHF y+CwaSJQM9MYfMkbgwJiB+BuKX5a92aDyac0tYCJ5DQesjsgBPCXKuZYbJdYkt4iLXCzrpmk7Gv hmY= X-Google-Smtp-Source: AGHT+IFOMLXsdm4h/FyGD/5ohNWgnC5XRTJg1tsO458mi6xl8BXMQxywzhwdPFFYh2SSAvnbDMDBBQ== X-Received: by 2002:a17:902:e84c:b0:215:4757:9ef3 with SMTP id d9443c01a7336-21a83f338b0mr89063095ad.9.1736425508502; Thu, 09 Jan 2025 04:25:08 -0800 (PST) Received: from localhost.localdomain (utm3.nitt.edu. [14.139.162.2]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-21a91768814sm11496435ad.18.2025.01.09.04.25.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2025 04:25:08 -0800 (PST) From: 45mg <45mg.writes@gmail.com> Date: Thu, 9 Jan 2025 12:24:31 +0000 Message-ID: <6c5c3ce265d159c862de73a77e985cf30a1f30a8.1736423822.git.45mg.writes@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <7743f403ebf1693fc386a397e9aed1975b43f900.1735323486.git.45mg.writes@gmail.com> References: <7743f403ebf1693fc386a397e9aed1975b43f900.1735323486.git.45mg.writes@gmail.com> 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 Allow users to specify additional configuration files for NetworkManager. These files will be added to `/etc/NetworkManager/conf.d` (NetworkManager's default configuration directory location). * gnu/services/networking.scm () [extra-configuration-files]: New field. (network-manager-configuration-directory): New procedure. (network-manager-activation): Honor the new field. * doc/guix.texi (Networking Setup): Document the new field. Change-Id: I07479958e4d0aa318328c666a9630b779230b300 --- doc/guix.texi | 21 +++++++++++++++++++++ gnu/services/networking.scm | 26 ++++++++++++++++++++++++-- 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index caebe3b03c..279fdb838b 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -21455,6 +21455,27 @@ Networking Setup (VPNs). An example of this is the @code{network-manager-openvpn} package, which allows NetworkManager to manage VPNs @i{via} OpenVPN. +@item @code{extra-configuration-files} (default: @code{'()}) +An alist of file names to file-like objects, representing configuration +files which will be added to @file{/etc/NetworkManager/conf.d}. +NetworkManager will read additional configuration from this directory. +For details on configuration file precedence and the configuration file +format, see the @command{NetworkManager.conf(5)} man page. + +For example, to add two files @file{001-basic.conf} and +@file{002-unmanaged.conf}: + +@lisp +(service network-manager-service-type + (network-manager-configuration + (extra-configuration-files + `(("existing-file" ,(local-file "001-basic.conf")) + ("constructed-file" ,(plain-file "002-unmanaged.conf" + "[keyfile] +unmanaged-devices=interface-name:wlo1_ap +")))))) +@end lisp + @end table @end deftp diff --git a/gnu/services/networking.scm b/gnu/services/networking.scm index 48a86b3694..4355158225 100644 --- a/gnu/services/networking.scm +++ b/gnu/services/networking.scm @@ -1262,18 +1262,40 @@ (define-record-type* (default '())) (iwd? network-manager-configuration-iwd? ; TODO: deprecated field, remove. (default #f) - (sanitize warn-iwd?-field-deprecation))) + (sanitize warn-iwd?-field-deprecation)) + (extra-configuration-files network-manager-configuration-extra-configuration-files + (default '()))) ;alist of file names to file-like objects + +(define (network-manager-configuration-directory extra-configuration-files) + "Return a directory containing EXTRA-CONFIGURATION-FILES." + (with-imported-modules (source-module-closure '((guix build utils))) + (computed-file + "network-manager-configuration-directory" + #~(begin + (use-modules (guix build utils)) + (mkdir-p #$output) + (for-each (lambda (pair) + (let* ((filename (list-ref pair 0)) + (file (list-ref pair 1)) + (dest (string-append #$output "/" filename))) + (copy-file file dest))) + '#$extra-configuration-files))))) (define (network-manager-activation config) ;; Activation gexp for NetworkManager (match-record config - (network-manager dns vpn-plugins) + (network-manager dns vpn-plugins extra-configuration-files) #~(begin (use-modules (guix build utils)) (mkdir-p "/etc/NetworkManager/system-connections") #$@(if (equal? dns "dnsmasq") ;; create directory to store dnsmasq lease file '((mkdir-p "/var/lib/misc")) + '()) + #$@(if extra-configuration-files + `((symlink + ,(network-manager-configuration-directory extra-configuration-files) + "/etc/NetworkManager/conf.d")) '())))) (define (vpn-plugin-directory plugins)