Subject: [bug#75145] [PATCH v4] services: network-manager: Add extra-configuration-files field.

From: 45mg <[email-masked]>
Date: Wed, 12 Feb 2025 09:56:42 +0000

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
---
 gnu/services/networking.scm | 19 +++----------------
 1 file changed, 3 insertions(+), 16 deletions(-)

diff --git a/gnu/services/networking.scm b/gnu/services/networking.scm
index a5aa86fd43..c93ed58cf5 100644
--- a/gnu/services/networking.scm
+++ b/gnu/services/networking.scm
@@ -23,6 +23,7 @@
 ;;; Copyright © 2023 Bruno Victal <[email-masked]>
 ;;; Copyright © 2023 muradm <[email-masked]>
 ;;; Copyright © 2024 Nigko Yerden <[email-masked]>
+;;; Copyright © 2025 45mg <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -1257,21 +1258,6 @@ (define-record-type* <network-manager-configuration>
   (extra-configuration-files network-manager-configuration-extra-configuration-files
                              (default '())))  ;'((file-name-string file-like-object) ...)
 
-(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-configuration>
@@ -1285,7 +1271,8 @@ (define (network-manager-activation config)
                '())
         #$@(if (pair? extra-configuration-files)  ;if non-empty
                `((symlink
-                  ,(network-manager-configuration-directory extra-configuration-files)
+                  ,(file-union "network-manager-configuration-directory"
+                               extra-configuration-files)
                   "/etc/NetworkManager/conf.d"))
                '()))))

base-commit: d59a13b6401e7494d8d5c9c9f66df3318451be79
prerequisite-patch-id: 8f30976d00586f571762f6333bf29dd355a64dbb
-- 
2.48.1