[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
02/03: services: networking: Add a dependency override mechanism to <sta
From: |
Marius Bakke |
Subject: |
02/03: services: networking: Add a dependency override mechanism to <static-networking>. |
Date: |
Fri, 29 Dec 2017 08:12:25 -0500 (EST) |
mbakke pushed a commit to branch master
in repository guix.
commit db8ed7cee81cbd60b0f8d89a7bee377b369fdac1
Author: Marius Bakke <address@hidden>
Date: Tue Oct 31 21:38:21 2017 +0100
services: networking: Add a dependency override mechanism to
<static-networking>.
* gnu/services/networking.scm (<static-networking>)[requirement]: New field.
(static-networking-shepherd-service): Don't override requirement for
loopback.
(static-networking-service): Expose 'requirement' parameter. Default to
UDEV.
* gnu/services/base.scm (%base-services): Add (requirement '()) for
loopback service.
* doc/guix.texi (Networking Services): Document it.
---
doc/guix.texi | 5 ++++-
gnu/services/base.scm | 1 +
gnu/services/networking.scm | 14 +++++++++-----
3 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/doc/guix.texi b/doc/guix.texi
index d925b4e..ad018ff 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -10392,9 +10392,12 @@ This is the type for statically-configured network
interfaces.
@deffn {Scheme Procedure} static-networking-service @var{interface} @var{ip} @
[#:netmask #f] [#:gateway #f] [#:name-servers @code{'()}]
+ [#:requirement @code{'(udev)}]
Return a service that starts @var{interface} with address @var{ip}. If
@var{netmask} is true, use it as the network mask. If @var{gateway} is true,
-it must be a string specifying the default network gateway.
+it must be a string specifying the default network gateway. @var{requirement}
+can be used to declare a dependency on another service before configuring the
+interface.
This procedure can be called several times, one for each network
interface of interest. Behind the scenes what it does is extend
diff --git a/gnu/services/base.scm b/gnu/services/base.scm
index 7fc8f6a..f4681c8 100644
--- a/gnu/services/base.scm
+++ b/gnu/services/base.scm
@@ -1986,6 +1986,7 @@ This service is not part of @var{%base-services}."
(service static-networking-service-type
(list (static-networking (interface "lo")
(ip "127.0.0.1")
+ (requirement '())
(provision '(loopback)))))
(syslog-service)
(service urandom-seed-service-type)
diff --git a/gnu/services/networking.scm b/gnu/services/networking.scm
index b0c23aa..c3ba078 100644
--- a/gnu/services/networking.scm
+++ b/gnu/services/networking.scm
@@ -5,6 +5,7 @@
;;; Copyright © 2016 John Darrington <address@hidden>
;;; Copyright © 2017 Clément Lassieur <address@hidden>
;;; Copyright © 2017 Thomas Danckaert <address@hidden>
+;;; Copyright © 2017 Marius Bakke <address@hidden>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -51,6 +52,7 @@
static-networking-ip
static-networking-netmask
static-networking-gateway
+ static-networking-requirement
static-networking-service
static-networking-service-type
@@ -145,22 +147,21 @@ fe80::1%lo0 apps.facebook.com\n")
(default #f))
(provision static-networking-provision
(default #f))
+ (requirement static-networking-requirement
+ (default '()))
(name-servers static-networking-name-servers ;FIXME: doesn't belong here
(default '())))
(define static-networking-shepherd-service
(match-lambda
(($ <static-networking> interface ip netmask gateway provision
- name-servers)
+ requirement name-servers)
(let ((loopback? (and provision (memq 'loopback provision))))
(shepherd-service
- ;; Unless we're providing the loopback interface, wait for udev to be
up
- ;; and running so that INTERFACE is actually usable.
- (requirement (if loopback? '() '(udev)))
-
(documentation
"Bring up the networking interface using a static IP address.")
+ (requirement requirement)
(provision (or provision
(list (symbol-append 'networking-
(string->symbol interface)))))
@@ -263,6 +264,8 @@ network interface.")))
(define* (static-networking-service interface ip
#:key
netmask gateway provision
+ ;; Most interfaces require udev to be
usable.
+ (requirement '(udev))
(name-servers '()))
"Return a service that starts @var{interface} with address @var{ip}. If
@var{netmask} is true, use it as the network mask. If @var{gateway} is true,
@@ -277,6 +280,7 @@ to handle."
(list (static-networking (interface interface) (ip ip)
(netmask netmask) (gateway gateway)
(provision provision)
+ (requirement requirement)
(name-servers name-servers)))))
(define dhcp-client-service-type