summaryrefslogtreecommitdiff
path: root/gnu/system
diff options
context:
space:
mode:
authorArun Isaac <arunisaac@systemreboot.net>2019-05-25 11:49:42 +0530
committerArun Isaac <arunisaac@systemreboot.net>2019-06-19 00:19:47 +0530
commitb84c4cda046589658c4d1ba4a9c0b292351fe5ca (patch)
treefb98916e5e63d5ce71d4c40dc89135206583b819 /gnu/system
parentcb13618b6d2293e39ab4722d541dd8720e4d1812 (diff)
linux-container: Remove networking service when network is shared with host.
* gnu/system/linux-container.scm (dummy-networking-service-type): New variable. (containerized-operating-system): If network is shared with host, replace static-networking-service-type with dummy-networking-service-type.
Diffstat (limited to 'gnu/system')
-rw-r--r--gnu/system/linux-container.scm29
1 files changed, 24 insertions, 5 deletions
diff --git a/gnu/system/linux-container.scm b/gnu/system/linux-container.scm
index c1e963d0473..61248c62b96 100644
--- a/gnu/system/linux-container.scm
+++ b/gnu/system/linux-container.scm
@@ -30,6 +30,7 @@
30 #:use-module (gnu build linux-container) 30 #:use-module (gnu build linux-container)
31 #:use-module (gnu services) 31 #:use-module (gnu services)
32 #:use-module (gnu services base) 32 #:use-module (gnu services base)
33 #:use-module (gnu services shepherd)
33 #:use-module (gnu system) 34 #:use-module (gnu system)
34 #:use-module (gnu system file-systems) 35 #:use-module (gnu system file-systems)
35 #:export (system-container 36 #:export (system-container
@@ -65,6 +66,16 @@ from OS that are needed on the bare metal and not in a container."
65 files))) 66 files)))
66 base))) 67 base)))
67 68
69(define dummy-networking-service-type
70 (shepherd-service-type
71 'dummy-networking
72 (const (shepherd-service
73 (documentation "Provide loopback and networking without actually
74doing anything.")
75 (provision '(loopback networking))
76 (start #~(const #t))))
77 #f))
78
68(define* (containerized-operating-system os mappings 79(define* (containerized-operating-system os mappings
69 #:key 80 #:key
70 shared-network? 81 shared-network?
@@ -96,7 +107,8 @@ containerized OS. EXTRA-FILE-SYSTEMS is a list of file systems to add to OS."
96 agetty-service-type) 107 agetty-service-type)
97 ;; Remove nscd service if network is shared with the host. 108 ;; Remove nscd service if network is shared with the host.
98 (if shared-network? 109 (if shared-network?
99 (list nscd-service-type) 110 (list nscd-service-type
111 static-networking-service-type)
100 (list)))) 112 (list))))
101 113
102 (operating-system 114 (operating-system
@@ -105,10 +117,17 @@ containerized OS. EXTRA-FILE-SYSTEMS is a list of file systems to add to OS."
105 (essential-services (container-essential-services 117 (essential-services (container-essential-services
106 this-operating-system 118 this-operating-system
107 #:shared-network? shared-network?)) 119 #:shared-network? shared-network?))
108 (services (remove (lambda (service) 120 (services (append (remove (lambda (service)
109 (memq (service-kind service) 121 (memq (service-kind service)
110 useless-services)) 122 useless-services))
111 (operating-system-user-services os))) 123 (operating-system-user-services os))
124 ;; Many Guix services depend on a 'networking' shepherd
125 ;; service, so make sure to provide a dummy 'networking'
126 ;; service when we are sure that networking is already set up
127 ;; in the host and can be used. That prevents double setup.
128 (if shared-network?
129 (list (service dummy-networking-service-type))
130 '())))
112 (file-systems (append (map mapping->fs 131 (file-systems (append (map mapping->fs
113 (if shared-network? 132 (if shared-network?
114 (append %network-file-mappings mappings) 133 (append %network-file-mappings mappings)