From 9fcc355529838f86f963dbdd7e47c0308df95a29 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Tue, 24 Sep 2013 23:15:09 +0200 Subject: gnu: vm: Add a service for the Guix daemon. * gnu/system/dmd.scm (guix-service): New procedure. * gnu/system/vm.scm (system-qemu-image): Use it. --- gnu/system/dmd.scm | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'gnu/system/dmd.scm') diff --git a/gnu/system/dmd.scm b/gnu/system/dmd.scm index 1e8767e357..a502c42e03 100644 --- a/gnu/system/dmd.scm +++ b/gnu/system/dmd.scm @@ -23,6 +23,8 @@ (define-module (gnu system dmd) #:use-module (guix records) #:use-module ((gnu packages system) #:select (mingetty inetutils)) + #:use-module ((gnu packages package-management) + #:select (guix)) #:use-module (ice-9 match) #:use-module (srfi srfi-1) #:export (service? @@ -36,6 +38,7 @@ (define-module (gnu system dmd) syslog-service mingetty-service + guix-service dmd-configuration-file)) ;;; Commentary: @@ -104,6 +107,17 @@ (define syslog.conf (inputs `(("inetutils" ,inetutils) ("syslog.conf" ,syslog.conf)))))) +(define* (guix-service store #:key (guix guix)) + "Return a service that runs the build daemon from GUIX." + (let* ((drv (package-derivation store guix)) + (daemon (string-append (derivation->output-path drv) + "/bin/guix-daemon"))) + (service + (provision '(guix-daemon)) + (start `(make-forkexec-constructor ,daemon)) + (inputs `(("guix" ,guix)))))) + + (define (dmd-configuration-file store services) "Return the dmd configuration file for SERVICES." (define config -- cgit v1.2.3 From ba47851fac503f005d2bc496161638c46cc29ffc Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Wed, 25 Sep 2013 21:49:22 +0200 Subject: gnu: vm: Add 'host-name' service. * gnu/system/dmd.scm (host-name-service): New procedure. (mingetty-service): Require the 'host-name' service. * gnu/system/vm.scm (system-qemu-image): Add the 'host-name' service. Set PS1 in /etc/bashrc to something sensible. --- gnu/system/dmd.scm | 14 ++++++++++++++ gnu/system/vm.scm | 4 +++- 2 files changed, 17 insertions(+), 1 deletion(-) (limited to 'gnu/system/dmd.scm') diff --git a/gnu/system/dmd.scm b/gnu/system/dmd.scm index a502c42e03..5bdf7b7a05 100644 --- a/gnu/system/dmd.scm +++ b/gnu/system/dmd.scm @@ -36,6 +36,7 @@ (define-module (gnu system dmd) service-stop service-inputs + host-name-service syslog-service mingetty-service guix-service @@ -61,6 +62,14 @@ (define-record-type* (inputs service-inputs ; list of inputs (default '()))) +(define (host-name-service store name) + "Return a service that sets the host name to NAME." + (service + (provision '(host-name)) + (start `(lambda _ + (sethostname ,name))) + (respawn? #f))) + (define (mingetty-service store tty) "Return a service to run mingetty on TTY." (let* ((mingetty-drv (package-derivation store mingetty)) @@ -68,6 +77,11 @@ (define (mingetty-service store tty) "/sbin/mingetty"))) (service (provision (list (symbol-append 'term- (string->symbol tty)))) + + ;; Since the login prompt shows the host name, wait for the 'host-name' + ;; service to be done. + (requirement '(host-name)) + (start `(make-forkexec-constructor ,mingetty-bin "--noclear" ,tty)) (inputs `(("mingetty" ,mingetty)))))) diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm index e79a4257de..0cab3ced17 100644 --- a/gnu/system/vm.scm +++ b/gnu/system/vm.scm @@ -447,7 +447,8 @@ (define %pam-services (define %dmd-services ;; Services run by dmd. - (list (mingetty-service store "tty1") + (list (host-name-service store "gnu") + (mingetty-service store "tty1") (mingetty-service store "tty2") (mingetty-service store "tty3") (mingetty-service store "tty4") @@ -488,6 +489,7 @@ (define %dmd-services (profile (derivation->output-path profile-drv)) (bashrc (add-text-to-store store "bashrc" (string-append " +export PS1='\\u@\\h\\$ ' export PATH=$HOME/.guix-profile/bin:" profile "/bin:" profile "/sbin export CPATH=$HOME/.guix-profile/include:" profile "/include export LIBRARY_PATH=$HOME/.guix-profile/lib:" profile "/lib -- cgit v1.2.3 From f83e943fe7b7a4db93a6c603b9fdde57a35e918d Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Wed, 25 Sep 2013 23:26:08 +0200 Subject: gnu: vm: Add 'networking' service. * gnu/system/vm.scm (system-qemu-image): Use 'static-networking-service'. Add /etc/resolv.conf. Add Inetutils to the profile. * gnu/system/dmd.scm (static-networking-service): New procedure. --- gnu/system/dmd.scm | 18 ++++++++++++++++++ gnu/system/vm.scm | 13 ++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) (limited to 'gnu/system/dmd.scm') diff --git a/gnu/system/dmd.scm b/gnu/system/dmd.scm index 5bdf7b7a05..7fc4650c25 100644 --- a/gnu/system/dmd.scm +++ b/gnu/system/dmd.scm @@ -40,6 +40,8 @@ (define-module (gnu system dmd) syslog-service mingetty-service guix-service + static-networking-service + dmd-configuration-file)) ;;; Commentary: @@ -131,6 +133,22 @@ (define* (guix-service store #:key (guix guix)) (start `(make-forkexec-constructor ,daemon)) (inputs `(("guix" ,guix)))))) +(define* (static-networking-service store interface ip + #:key (inetutils inetutils)) + "Return a service that starts INTERFACE with address IP." + + ;; TODO: Eventually we should do this using Guile's networking procedures, + ;; like 'configure-qemu-networking' does, but the patch that does this is + ;; not yet in stock Guile. + (let ((ifconfig (string-append (package-output store inetutils) + "/bin/ifconfig"))) + (service + (provision '(networking)) + (start `(make-forkexec-constructor ,ifconfig ,interface ,ip "up")) + (stop `(make-forkexec-constructor ,ifconfig ,interface "down")) + (respawn? #f) + (inputs `(("inetutils" ,inetutils)))))) + (define (dmd-configuration-file store services) "Return the dmd configuration file for SERVICES." diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm index dd97e5ee0d..b873386606 100644 --- a/gnu/system/vm.scm +++ b/gnu/system/vm.scm @@ -455,7 +455,15 @@ (define %dmd-services (mingetty-service store "tty5") (mingetty-service store "tty6") (syslog-service store) - (guix-service store #:guix guix-0.4))) + (guix-service store #:guix guix-0.4) + + ;; QEMU networking settings. + (static-networking-service store "eth0" "10.0.2.10"))) + + (define resolv.conf + ;; Name resolution for default QEMU settings. + (add-text-to-store store "resolv.conf" + "nameserver 10.0.2.3\n")) (parameterize ((%guile-for-build (package-derivation store guile-final))) (let* ((bash-drv (package-derivation store bash)) @@ -480,6 +488,7 @@ (define %dmd-services ("dmd" ,dmd) ("gcc" ,gcc-final) ("libc" ,glibc-final) + ("inetutils" ,inetutils) ("guix" ,guix-0.4))) ;; TODO: Replace with a real profile with a manifest. @@ -514,6 +523,7 @@ (define %dmd-services ("/etc/passwd" -> ,passwd) ("/etc/login.defs" -> "/dev/null") ("/etc/pam.d" -> ,pam.d) + ("/etc/resolv.conf" -> ,resolv.conf) ("/etc/profile" -> ,bashrc) ("/etc/issue" -> ,issue) (directory "/var/nix/gcroots") @@ -552,6 +562,7 @@ (define %dmd-services ("etc-passwd" ,passwd) ("etc-shadow" ,shadow) ("etc-group" ,group) + ("etc-resolv.conf" ,resolv.conf) ("etc-bashrc" ,bashrc) ("etc-issue" ,issue) ("etc-motd" ,motd) -- cgit v1.2.3 From 349746dfcd9a07e3b5908d459d0800fd5d44c3b9 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Thu, 26 Sep 2013 00:07:42 +0200 Subject: gnu: vm: Add nscd service. * gnu/system/dmd.scm (nscd-service): New procedure. * gnu/system/vm.scm (system-qemu-image): Use it. Make /var/run/nscd. --- gnu/system/dmd.scm | 21 +++++++++++++++++++++ gnu/system/vm.scm | 5 +++-- 2 files changed, 24 insertions(+), 2 deletions(-) (limited to 'gnu/system/dmd.scm') diff --git a/gnu/system/dmd.scm b/gnu/system/dmd.scm index 7fc4650c25..b248d9f0c5 100644 --- a/gnu/system/dmd.scm +++ b/gnu/system/dmd.scm @@ -21,6 +21,8 @@ (define-module (gnu system dmd) #:use-module (guix packages) #:use-module (guix derivations) #:use-module (guix records) + #:use-module ((gnu packages base) + #:select (glibc-final)) #:use-module ((gnu packages system) #:select (mingetty inetutils)) #:use-module ((gnu packages package-management) @@ -39,6 +41,7 @@ (define-module (gnu system dmd) host-name-service syslog-service mingetty-service + nscd-service guix-service static-networking-service @@ -87,6 +90,24 @@ (define (mingetty-service store tty) (start `(make-forkexec-constructor ,mingetty-bin "--noclear" ,tty)) (inputs `(("mingetty" ,mingetty)))))) +(define* (nscd-service store + #:key (glibc glibc-final)) + "Return a service that runs libc's name service cache daemon (nscd)." + (let ((nscd (string-append (package-output store glibc) "/sbin/nscd"))) + (service + (provision '(nscd)) + (start `(make-forkexec-constructor ,nscd "-f" "/dev/null")) + + ;; XXX: Local copy of 'make-kill-destructor' because the one upstream + ;; uses the broken 'opt-lambda' macro. + (stop `(lambda* (#:optional (signal SIGTERM)) + (lambda (pid . args) + (kill pid signal) + #f))) + + (respawn? #f) + (inputs `(("glibc" ,glibc)))))) + (define (syslog-service store) "Return a service that runs 'syslogd' with reasonable default settings." diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm index b873386606..0ed805510a 100644 --- a/gnu/system/vm.scm +++ b/gnu/system/vm.scm @@ -456,6 +456,7 @@ (define %dmd-services (mingetty-service store "tty6") (syslog-service store) (guix-service store #:guix guix-0.4) + (nscd-service store) ;; QEMU networking settings. (static-networking-service store "eth0" "10.0.2.10"))) @@ -517,8 +518,8 @@ (define resolv.conf ")) (populate `((directory "/etc") - (directory "/var/log") - (directory "/var/run") + (directory "/var/log") ; for dmd + (directory "/var/run/nscd") ("/etc/shadow" -> ,shadow) ("/etc/passwd" -> ,passwd) ("/etc/login.defs" -> "/dev/null") -- cgit v1.2.3