GNU bug report logs - #75145
[PATCH] services: NetworkManager: configuration-directory

Previous Next

Package: guix-patches;

Reported by: 45mg <45mg.writes <at> gmail.com>

Date: Fri, 27 Dec 2024 18:23:02 UTC

Severity: normal

Tags: patch

Done: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
Cc: tracker <at> debbugs.gnu.org
Subject: bug#75145: closed ([PATCH] services: NetworkManager:
 configuration-directory)
Date: Wed, 12 Feb 2025 16:06:02 +0000
[Message part 1 (text/plain, inline)]
Your message dated Thu, 13 Feb 2025 01:05:09 +0900
with message-id <87pljnno7e.fsf <at> gmail.com>
and subject line Re: [PATCH v5] services: network-manager: Add extra-configuration-files field.
has caused the debbugs.gnu.org bug report #75145,
regarding [PATCH] services: NetworkManager: configuration-directory
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)


-- 
75145: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=75145
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: 45mg <45mg.writes <at> gmail.com>
To: guix-patches <at> gnu.org
Cc: 45mg <45mg.writes <at> gmail.com>
Subject: [PATCH] services: NetworkManager: configuration-directory
Date: Fri, 27 Dec 2024 13:18:06 -0500
Give users a way to configure NetworkManager, by specifying a directory
containing configuration files. This directory will then be symlinked to
`/etc/NetworkManager/conf.d` (NetworkManager's default configuration
directory location).

* gnu/services/networking.scm (<network-manager-configuration>)
[configuration-directory]: new option.
* doc/guix.texi: document it.

Change-Id: I243a71593b9235cc11ebf9fea1926a1840d993d2
---
 doc/guix.texi               | 30 ++++++++++++++++++++++++++++++
 gnu/services/networking.scm | 10 ++++++++--
 2 files changed, 38 insertions(+), 2 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index da4d2f5ebc..ee0fbf59f9 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -21441,6 +21441,36 @@ 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{configuration-directory} (default: @code{#f})
+A directory (file-like object) that will be symlinked as
+@file{/etc/NetworkManager/conf.d}. NetworkManager will read
+configuration files from this directory. For the configuration file
+format, see the @command{NetworkManager.conf(5)} man page.
+
+For example, you could supply an existing directory:
+
+@lisp
+(service network-manager-service-type
+         (network-manager-configuration
+          (configuration-directory
+           (local-file "files/NetworkManager/conf.d" #:recursive? #t))))
+@end lisp
+
+Or create a directory using @code{file-union}:
+
+@lisp
+(service network-manager-service-type
+         (network-manager-configuration
+          (configuration-directory
+           (file-union "my-configuration-directory"
+                       `(("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..7152c5a95f 100644
--- a/gnu/services/networking.scm
+++ b/gnu/services/networking.scm
@@ -23,6 +23,7 @@
 ;;; Copyright © 2023 Bruno Victal <mirai <at> makinata.eu>
 ;;; Copyright © 2023 muradm <mail <at> muradm.net>
 ;;; Copyright © 2024 Nigko Yerden <nigko.yerden <at> gmail.com>
+;;; Copyright © 2024 45mg <45mg.writes <at> gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -1262,18 +1263,23 @@ (define-record-type* <network-manager-configuration>
                (default '()))
   (iwd? network-manager-configuration-iwd?  ; TODO: deprecated field, remove.
         (default #f)
-        (sanitize warn-iwd?-field-deprecation)))
+        (sanitize warn-iwd?-field-deprecation))
+  (configuration-directory network-manager-configuration-configuration-directory ;file-like
+                           (default #f)))
 
 (define (network-manager-activation config)
   ;; Activation gexp for NetworkManager
   (match-record config <network-manager-configuration>
-    (network-manager dns vpn-plugins)
+    (network-manager dns vpn-plugins configuration-directory)
     #~(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 configuration-directory
+               `((symlink ,configuration-directory "/etc/NetworkManager/conf.d"))
                '()))))
 
 (define (vpn-plugin-directory plugins)

base-commit: 831b94a1efcea8f793afc949b5123a6235c9bb1a
-- 
2.47.1



[Message part 3 (message/rfc822, inline)]
From: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
To: 45mg <45mg.writes <at> gmail.com>
Cc: 75145-done <at> debbugs.gnu.org, Arnaud Daby-Seesaram <ds-ac <at> nanein.fr>,
 Ludovic Courtès <ludo <at> gnu.org>
Subject: Re: [PATCH v5] services: network-manager: Add
 extra-configuration-files field.
Date: Thu, 13 Feb 2025 01:05:09 +0900
Hello!

45mg <45mg.writes <at> gmail.com> writes:

> 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 (<network-manager-configuration>)
> [extra-configuration-files]: New field.
> (network-manager-activation): Honor the new field.
> * doc/guix.texi (Networking Setup): Document the new field.
>
> Change-Id: I07479958e4d0aa318328c666a9630b779230b300

LGTM.  I've taken the liberty to apply the following nitpick edits:

--8<---------------cut here---------------start------------->8---
modified   doc/guix.texi
@@ -21639,13 +21639,13 @@ Networking Setup
 @item @code{extra-configuration-files} (default: @code{'()})
 A list of two-element lists; the first element of each list is a file
 name (as a string), and the second is a file-like object.  Used to
-specify configuration files which will be added to
+specify configuration files which will be added to the
 @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.
+precedence and the configuration file format, see @samp{man 5
+NetworkManager.conf}.
 
-For example, to add two files @file{001-basic.conf} and
+For example, to add two files named @file{001-basic.conf} and
 @file{002-unmanaged.conf}:
 
 @lisp
@@ -21655,8 +21655,7 @@ Networking Setup
            `(("existing-file" ,(local-file "001-basic.conf"))
              ("constructed-file" ,(plain-file "002-unmanaged.conf"
                                               "[keyfile]
-unmanaged-devices=interface-name:wlo1_ap
-"))))))
+unmanaged-devices=interface-name:wlo1_ap\n"))))))
 @end lisp
 
 @end table
modified   gnu/services/networking.scm
@@ -1255,8 +1255,9 @@ (define-record-type* <network-manager-configuration>
   (iwd? network-manager-configuration-iwd?  ; TODO: deprecated field, remove.
         (default #f)
         (sanitize warn-iwd?-field-deprecation))
-  (extra-configuration-files network-manager-configuration-extra-configuration-files
-                             (default '())))  ;'((file-name-string file-like-object) ...)
+  (extra-configuration-files
+   network-manager-configuration-extra-configuration-files
+   (default '())))                 ;'((file-name-string file-like-object) ...)
 
 (define (network-manager-activation config)
   ;; Activation gexp for NetworkManager
--8<---------------cut here---------------end--------------->8---

I hope that's fine.

Finally pushed as commit 0caba8f5db!  Thank you for contributing to Guix!

--
Maxim


This bug report was last modified 153 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.