From c65e1834032d7f6e1bc4ebbc8157389a922f1e99 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Thu, 11 Sep 2014 22:03:24 +0200 Subject: system: Add 'hosts-file' field. * gnu/system.scm ()[hosts-file]: New field. (default-/etc/hosts): New procedure. (etc-directory): Add #:hosts-file parameter and honor it. (operating-system-etc-directory): Build /etc/hosts, and pass it as #:hosts-file to 'etc-directory'. --- gnu/system.scm | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'gnu') diff --git a/gnu/system.scm b/gnu/system.scm index 067f4e1634..20fe1d0a8f 100644 --- a/gnu/system.scm +++ b/gnu/system.scm @@ -55,6 +55,7 @@ operating-system-user-services operating-system-packages operating-system-host-name + operating-system-hosts-file operating-system-kernel operating-system-initrd operating-system-users @@ -92,6 +93,8 @@ (default base-initrd)) (host-name operating-system-host-name) ; string + (hosts-file operating-system-hosts-file ; M item | #f + (default #f)) (file-systems operating-system-file-systems) ; list of fs @@ -221,12 +224,19 @@ explicitly appear in OS." " This is the GNU system. Welcome.\n") +(define (default-/etc/hosts host-name) + "Return the default /etc/hosts file." + (text-file "hosts" + (string-append "localhost 127.0.0.1\n" + host-name " 127.0.0.1\n"))) + (define* (etc-directory #:key (locale "C") (timezone "Europe/Paris") (issue "Hello!\n") (skeletons '()) (pam-services '()) (profile "/run/current-system/profile") + hosts-file (sudoers "")) "Return a derivation that builds the static part of the /etc directory." (mlet* %store-monad @@ -269,6 +279,7 @@ alias ll='ls -l' ("skel" ,#~#$skel) ("shells" ,#~#$shells) ("profile" ,#~#$bashrc) + ("hosts" ,#~#$hosts-file) ("localtime" ,#~(string-append #$tzdata "/share/zoneinfo/" #$timezone)) ("sudoers" ,#~#$sudoers))))) @@ -311,12 +322,15 @@ alias ll='ls -l' (append (operating-system-pam-services os) (append-map service-pam-services services)))) (profile-drv (operating-system-profile os)) - (skeletons (operating-system-skeletons os))) + (skeletons (operating-system-skeletons os)) + (/etc/hosts (or (operating-system-hosts-file os) + (default-/etc/hosts (operating-system-host-name os))))) (etc-directory #:pam-services pam-services #:skeletons skeletons #:issue (operating-system-issue os) #:locale (operating-system-locale os) #:timezone (operating-system-timezone os) + #:hosts-file /etc/hosts #:sudoers (operating-system-sudoers os) #:profile profile-drv))) -- cgit v1.2.3