gnu: Move /etc/resolv.conf handling to the networking service.

* gnu/system/vm.scm (etc-directory): Remove 'resolv.conf'.
  (system-qemu-image): Use 'static-networking-service' with
  #:name-servers.  Don't populate the image with /etc/resolv.conf.
* gnu/system/dmd.scm (static-networking-service): Add #:name-servers
  parameter.  Use it to populate /etc/resolv.conf.
This commit is contained in:
Ludovic Courtès 2013-12-06 23:58:46 +01:00
parent 0b8a376b68
commit a348b09ea9
2 changed files with 14 additions and 7 deletions

View File

@ -163,6 +163,7 @@
(define* (static-networking-service interface ip (define* (static-networking-service interface ip
#:key #:key
gateway gateway
(name-servers '())
(inetutils inetutils) (inetutils inetutils)
(net-tools net-tools)) (net-tools net-tools))
"Return a service that starts INTERFACE with address IP. If GATEWAY is "Return a service that starts INTERFACE with address IP. If GATEWAY is
@ -185,6 +186,17 @@ true, it must be a string specifying the default network gateway."
,(if gateway ,(if gateway
`(zero? (system* ,route "add" "-net" "default" `(zero? (system* ,route "add" "-net" "default"
"gw" ,gateway)) "gw" ,gateway))
#t)
,(if (pair? name-servers)
`(call-with-output-file "/etc/resolv.conf"
(lambda (port)
(display
"# Generated by 'static-networking-service'.\n"
port)
(for-each (lambda (server)
(format port "nameserver ~a~%"
server))
',name-servers)))
#t)))) #t))))
(stop `(lambda _ (stop `(lambda _
;; Return #f is successfully stopped. ;; Return #f is successfully stopped.

View File

@ -517,10 +517,6 @@ export LIBRARY_PATH=$HOME/.guix-profile/lib:" profile "/lib
alias ls='ls -p --color' alias ls='ls -p --color'
alias ll='ls -l' alias ll='ls -l'
"))) ")))
(resolv.conf
;; Name resolution for default QEMU settings.
;; FIXME: Move to networking service.
(text-file "resolv.conf" "nameserver 10.0.2.3\n"))
(files -> `(("services" ,services) (files -> `(("services" ,services)
("protocols" ,protocols) ("protocols" ,protocols)
@ -531,8 +527,7 @@ alias ll='ls -l'
("profile" ,bashrc) ("profile" ,bashrc)
("passwd" ,passwd) ("passwd" ,passwd)
("shadow" ,shadow) ("shadow" ,shadow)
("group" ,group) ("group" ,group))))
("resolv.conf" ,resolv.conf))))
(file-union files (file-union files
#:inputs `(("net" ,net-base) #:inputs `(("net" ,net-base)
("pam.d" ,pam.d)) ("pam.d" ,pam.d))
@ -557,6 +552,7 @@ alias ll='ls -l'
;; QEMU networking settings. ;; QEMU networking settings.
(static-networking-service "eth0" "10.0.2.10" (static-networking-service "eth0" "10.0.2.10"
#:name-servers '("10.0.2.3")
#:gateway "10.0.2.2"))) #:gateway "10.0.2.2")))
(motd (text-file "motd" " (motd (text-file "motd" "
Happy birthday, GNU! http://www.gnu.org/gnu30 Happy birthday, GNU! http://www.gnu.org/gnu30
@ -636,7 +632,6 @@ Happy birthday, GNU! http://www.gnu.org/gnu30
("/etc/group" -> "/etc/static/group") ("/etc/group" -> "/etc/static/group")
("/etc/login.defs" -> "/etc/static/login.defs") ("/etc/login.defs" -> "/etc/static/login.defs")
("/etc/pam.d" -> "/etc/static/pam.d") ("/etc/pam.d" -> "/etc/static/pam.d")
("/etc/resolv.conf" -> "/etc/static/resolv.conf")
("/etc/profile" -> "/etc/static/profile") ("/etc/profile" -> "/etc/static/profile")
("/etc/issue" -> "/etc/static/issue") ("/etc/issue" -> "/etc/static/issue")
("/etc/services" -> "/etc/static/services") ("/etc/services" -> "/etc/static/services")