>From 1e400957b29a47f63548df39b36a7c0f1d8a37d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=8B=E6=96=87=E6=AD=A6?=
Date: Tue, 2 Dec 2014 21:40:52 +0800 Subject: [PATCH] gnu: Add /etc/environment. * gnu/system.scm (default-/etc/environment): New procedure. (etc-directory)[profile]: Remove it. (etc-directory)[environment]: Add it. * gnu/system/linux.scm (unix-pam-service): Add #:readenv? parameter. * gnu/services/base.scm (mingetty-service): Pass #t as #:readenv? to unix-pam-service. * gnu/system/shadow.scm (default-skeletons): Add .bash_profile. Adjust .bashrc. --- gnu/services/base.scm | 3 ++- gnu/system.scm | 40 ++++++++++++++++++++-------------------- gnu/system/linux.scm | 26 ++++++++++++++++---------- gnu/system/shadow.scm | 18 +++++++++++++++--- 4 files changed, 53 insertions(+), 34 deletions(-) diff --git a/gnu/services/base.scm b/gnu/services/base.scm index 712222b..b8dedd7 100644 --- a/gnu/services/base.scm +++ b/gnu/services/base.scm @@ -372,7 +372,8 @@ the ``message of the day''." ;; duplicates are removed. (list (unix-pam-service "login" #:allow-empty-passwords? allow-empty-passwords? - #:motd motd))))))) + #:motd motd + #:readenv? #t))))))) (define* (nscd-service #:key (glibc (canonical-package glibc))) "Return a service that runs libc's name service cache daemon (nscd)." diff --git a/gnu/system.scm b/gnu/system.scm index 731f9de..b0cf59f 100644 --- a/gnu/system.scm +++ b/gnu/system.scm @@ -351,6 +351,21 @@ This is the GNU system. Welcome.\n") "Return the default /etc/hosts file." (text-file "hosts" (local-host-aliases host-name))) +(define* (default-/etc/environment #:key locale timezone) + "Return the default /etc/environment file." + (let* ((profile "/run/current-system/profile") + (path (string-join (list "/run/setuid-programs" + (string-append profile "/bin") + (string-append profile "/sbin")) + ":"))) + (text-file* "environment" "\ +LANG=" locale " +TZ=" timezone " +TZDIR=" tzdata "/share/zoneinfo +LINUX_MODULE_DIRECTORY=/run/booted-system/kernel/lib/modules +PATH=" path " +INFOPATH=/run/current-system/profile/share/info\n"))) + (define* (etc-directory #:key (locale "C") (timezone "Europe/Paris") (issue "Hello!\n") @@ -375,25 +390,10 @@ This is the GNU system. Welcome.\n") (nsswitch (text-file "nsswitch.conf" "hosts: files dns\n")) - ;; TODO: Generate bashrc from packages' search-paths. - (bashrc (text-file* "bashrc" " -export PS1='address@hidden \\w\\$ ' - -export LC_ALL=\"" locale "\" -export TZ=\"" timezone "\" -export TZDIR=\"" tzdata "/share/zoneinfo\" - -# Tell 'modprobe' & co. where to look for modules. -export LINUX_MODULE_DIRECTORY=/run/booted-system/kernel/lib/modules - -export PATH=$HOME/.guix-profile/bin:/run/current-system/profile/bin -export PATH=/run/setuid-programs:/run/current-system/profile/sbin:$PATH -export CPATH=$HOME/.guix-profile/include:" profile "/include -export LIBRARY_PATH=$HOME/.guix-profile/lib:" profile "/lib -export INFOPATH=$HOME/.guix-profile/share/info:/run/current-system/profile/share/info -alias ls='ls -p --color' -alias ll='ls -l' -")) + ;; Default system-wide environment varibales. + (environment (default-/etc/environment #:locale locale + #:timezone timezone)) + (skel (skeleton-directory skeletons))) (file-union "etc" `(("services" ,#~(string-append #$net-base "/etc/services")) @@ -405,7 +405,7 @@ alias ll='ls -l' ("nsswitch.conf" ,#~#$nsswitch) ("skel" ,#~#$skel) ("shells" ,#~#$shells) - ("profile" ,#~#$bashrc) + ("environment" ,#~#$environment) ("hosts" ,#~#$hosts-file) ("localtime" ,#~(string-append #$tzdata "/share/zoneinfo/" #$timezone)) diff --git a/gnu/system/linux.scm b/gnu/system/linux.scm index 8cddedf..f479251 100644 --- a/gnu/system/linux.scm +++ b/gnu/system/linux.scm @@ -127,10 +127,11 @@ dumped in /etc/pam.d/NAME, where NAME is the name of SERVICE." (let ((unix (pam-entry (control "required") (module "pam_unix.so")))) - (lambda* (name #:key allow-empty-passwords? motd) + (lambda* (name #:key allow-empty-passwords? motd readenv?) "Return a standard Unix-style PAM service for NAME. When ALLOW-EMPTY-PASSWORDS? is true, allow empty passwords. When MOTD is true, it -should be the name of a file used as the message-of-the-day." +should be the name of a file used as the message-of-the-day. When READENV? is +true, honor system-wide environment variables." ;; See