GNU bug report logs -
#75145
[PATCH] services: NetworkManager: configuration-directory
Previous Next
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
Message #77 received at 75145 <at> debbugs.gnu.org (full text, mbox):
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
---
doc/guix.texi | 24 ++++++++++++++++++++++++
gnu/services/networking.scm | 13 +++++++++++--
2 files changed, 35 insertions(+), 2 deletions(-)
diff --git a/doc/guix.texi b/doc/guix.texi
index ce780682ed..d71bed7838 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -21635,6 +21635,30 @@ 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{'()})
+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
+@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
+ `(("001-basic.conf" ,(local-file "basic.conf"))
+ ("002-unmanaged.conf" ,(plain-file "constructed-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 af28bd0626..c93ed58cf5 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 © 2025 45mg <45mg.writes <at> gmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -1253,18 +1254,26 @@ (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))
+ (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
(match-record config <network-manager-configuration>
- (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 (pair? extra-configuration-files) ;if non-empty
+ `((symlink
+ ,(file-union "network-manager-configuration-directory"
+ extra-configuration-files)
+ "/etc/NetworkManager/conf.d"))
'()))))
(define (vpn-plugin-directory plugins)
base-commit: d59a13b6401e7494d8d5c9c9f66df3318451be79
--
2.48.1
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.