mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2025-01-26 12:39:36 -05:00
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.
This commit is contained in:
parent
5859fd6c9e
commit
db8ed7cee8
3 changed files with 14 additions and 6 deletions
|
@ -10392,9 +10392,12 @@ This is the type for statically-configured network interfaces.
|
||||||
|
|
||||||
@deffn {Scheme Procedure} static-networking-service @var{interface} @var{ip} @
|
@deffn {Scheme Procedure} static-networking-service @var{interface} @var{ip} @
|
||||||
[#:netmask #f] [#:gateway #f] [#:name-servers @code{'()}]
|
[#:netmask #f] [#:gateway #f] [#:name-servers @code{'()}]
|
||||||
|
[#:requirement @code{'(udev)}]
|
||||||
Return a service that starts @var{interface} with address @var{ip}. If
|
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,
|
@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
|
This procedure can be called several times, one for each network
|
||||||
interface of interest. Behind the scenes what it does is extend
|
interface of interest. Behind the scenes what it does is extend
|
||||||
|
|
|
@ -1986,6 +1986,7 @@ (define %base-services
|
||||||
(service static-networking-service-type
|
(service static-networking-service-type
|
||||||
(list (static-networking (interface "lo")
|
(list (static-networking (interface "lo")
|
||||||
(ip "127.0.0.1")
|
(ip "127.0.0.1")
|
||||||
|
(requirement '())
|
||||||
(provision '(loopback)))))
|
(provision '(loopback)))))
|
||||||
(syslog-service)
|
(syslog-service)
|
||||||
(service urandom-seed-service-type)
|
(service urandom-seed-service-type)
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
;;; Copyright © 2016 John Darrington <jmd@gnu.org>
|
;;; Copyright © 2016 John Darrington <jmd@gnu.org>
|
||||||
;;; Copyright © 2017 Clément Lassieur <clement@lassieur.org>
|
;;; Copyright © 2017 Clément Lassieur <clement@lassieur.org>
|
||||||
;;; Copyright © 2017 Thomas Danckaert <post@thomasdanckaert.be>
|
;;; Copyright © 2017 Thomas Danckaert <post@thomasdanckaert.be>
|
||||||
|
;;; Copyright © 2017 Marius Bakke <mbakke@fastmail.com>
|
||||||
;;;
|
;;;
|
||||||
;;; This file is part of GNU Guix.
|
;;; This file is part of GNU Guix.
|
||||||
;;;
|
;;;
|
||||||
|
@ -51,6 +52,7 @@ (define-module (gnu services networking)
|
||||||
static-networking-ip
|
static-networking-ip
|
||||||
static-networking-netmask
|
static-networking-netmask
|
||||||
static-networking-gateway
|
static-networking-gateway
|
||||||
|
static-networking-requirement
|
||||||
|
|
||||||
static-networking-service
|
static-networking-service
|
||||||
static-networking-service-type
|
static-networking-service-type
|
||||||
|
@ -145,22 +147,21 @@ (define-record-type* <static-networking>
|
||||||
(default #f))
|
(default #f))
|
||||||
(provision static-networking-provision
|
(provision static-networking-provision
|
||||||
(default #f))
|
(default #f))
|
||||||
|
(requirement static-networking-requirement
|
||||||
|
(default '()))
|
||||||
(name-servers static-networking-name-servers ;FIXME: doesn't belong here
|
(name-servers static-networking-name-servers ;FIXME: doesn't belong here
|
||||||
(default '())))
|
(default '())))
|
||||||
|
|
||||||
(define static-networking-shepherd-service
|
(define static-networking-shepherd-service
|
||||||
(match-lambda
|
(match-lambda
|
||||||
(($ <static-networking> interface ip netmask gateway provision
|
(($ <static-networking> interface ip netmask gateway provision
|
||||||
name-servers)
|
requirement name-servers)
|
||||||
(let ((loopback? (and provision (memq 'loopback provision))))
|
(let ((loopback? (and provision (memq 'loopback provision))))
|
||||||
(shepherd-service
|
(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
|
(documentation
|
||||||
"Bring up the networking interface using a static IP address.")
|
"Bring up the networking interface using a static IP address.")
|
||||||
|
(requirement requirement)
|
||||||
(provision (or provision
|
(provision (or provision
|
||||||
(list (symbol-append 'networking-
|
(list (symbol-append 'networking-
|
||||||
(string->symbol interface)))))
|
(string->symbol interface)))))
|
||||||
|
@ -263,6 +264,8 @@ (define static-networking-service-type
|
||||||
(define* (static-networking-service interface ip
|
(define* (static-networking-service interface ip
|
||||||
#:key
|
#:key
|
||||||
netmask gateway provision
|
netmask gateway provision
|
||||||
|
;; Most interfaces require udev to be usable.
|
||||||
|
(requirement '(udev))
|
||||||
(name-servers '()))
|
(name-servers '()))
|
||||||
"Return a service that starts @var{interface} with address @var{ip}. If
|
"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,
|
@var{netmask} is true, use it as the network mask. If @var{gateway} is true,
|
||||||
|
@ -277,6 +280,7 @@ (define* (static-networking-service interface ip
|
||||||
(list (static-networking (interface interface) (ip ip)
|
(list (static-networking (interface interface) (ip ip)
|
||||||
(netmask netmask) (gateway gateway)
|
(netmask netmask) (gateway gateway)
|
||||||
(provision provision)
|
(provision provision)
|
||||||
|
(requirement requirement)
|
||||||
(name-servers name-servers)))))
|
(name-servers name-servers)))))
|
||||||
|
|
||||||
(define dhcp-client-service-type
|
(define dhcp-client-service-type
|
||||||
|
|
Loading…
Reference in a new issue