From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?utf-8?B?5a6L5paH5q2m?= Subject: Re: use zsh as login shell Date: Tue, 02 Dec 2014 22:43:20 +0800 Message-ID: <87wq6aun7b.fsf@gmail.com> References: <87k32gtz2p.fsf@gmail.com> <87mw7cjt7b.fsf@gnu.org> <87mw7b74ar.fsf@gmail.com> <8761dzynah.fsf@gnu.org> <87vblyy9ia.fsf@gmail.com> <87egsjcyst.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:34797) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xvofu-00032i-A7 for guix-devel@gnu.org; Tue, 02 Dec 2014 09:43:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xvofo-0006KQ-98 for guix-devel@gnu.org; Tue, 02 Dec 2014 09:43:34 -0500 In-Reply-To: <87egsjcyst.fsf@gnu.org> List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: Ludovic =?utf-8?Q?Court=C3=A8s?= Cc: guix-devel@gnu.org --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Ludovic Court=C3=A8s writes: > =E5=AE=8B=E6=96=87=E6=AD=A6 skribis: > >> Ludovic Court=C3=A8s writes: >> >>> =E5=AE=8B=E6=96=87=E6=AD=A6 skribis: >>> >>>> Ludovic Court=C3=A8s writes: > > [...] > >>> So, instead of what you suggest, what about having: >>> >>> 1. /etc/profile and /etc/zlogin (?) both source /etc/environment, >>> which uses plain Bourne syntax. >>> >>> 2. PATH is defined in /etc/environment and includes >>> ~/.guix-profile/bin. >> /etc/environment is defined by pam_env to be a simple KEY=3DVAL file, wi= th no >> support for varibales substitute. If we do not use pam_env (linux specif= ied?), >> I think we should let /etc/zlogin source /etc/profile instead. > > Yes, but they would contain almost the same lines, right? To what > extent is zsh Bourne- or Bash-compatible? Does =E2=80=98export foo=3Dbar= =E2=80=99 work > for zsh? It does. > > If it does, let=E2=80=99s just keep /etc/profile, and use it for both zsh= and > Bash. > >> And we don't want /etc/zlogin when not using zsh at all, >> IIUC while skeletons is configurable at the top os-expr, /etc/zlogin is >> not.=20 > > It=E2=80=99s OK to have a 2-KiB /etc/zlogin, even when one doesn=E2=80=99= t use zsh. > >>> 3. The skeleton for ~/.bash_profile sources /etc/profile, /etc/bashrc, >>> and ~/.bashrc. >>> >>> 4. The definition of PS1 is moved from /etc/profile to /etc/bashrc. >>> >>> 5. The skeleton for ~/.bashrc sources /etc/bashrc. >> It seem too much, what I suggested is: >> for login, su (pam_env): /etc/environment >> for login shell: ~/.bash_profile, ~/.zlogin >> for interactive: ~/.bashrc, ~/.zshrc >> skeletons only installed when needed :) > > As a first step, what about always installing the skeletons? Then we > can see whether/how to refine that. No problem. > > Thanks, > Ludo=E2=80=99. And this is what I have so far: --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-gnu-Add-etc-environment.patch >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='\\u@\\h \\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 . (let ((name* name)) (pam-service @@ -143,14 +144,19 @@ should be the name of a file used as the message-of-the-day." (arguments '("nullok"))) unix))) (password (list unix)) - (session (if motd - (list unix - (pam-entry - (control "optional") - (module "pam_motd.so") - (arguments - (list #~(string-append "motd=" #$motd))))) - (list unix)))))))) + (session (let ((motd-entry + (if motd + (pam-entry + (control "optional") + (module "pam_motd.so") + (arguments + (list #~(string-append "motd=" #$motd)))))) + (env-entry + (if readenv? + (pam-entry + (control "required") + (module "pam_env.so"))))) + (filter pam-entry? (list unix motd-entry env-entry))))))))) (define (rootok-pam-service command) "Return a PAM service for COMMAND such that 'root' does not need to diff --git a/gnu/system/shadow.scm b/gnu/system/shadow.scm index 6970021..926c385 100644 --- a/gnu/system/shadow.scm +++ b/gnu/system/shadow.scm @@ -115,9 +115,20 @@ (copy-file (car (find-files #$guile-wm "wm-init-sample.scm")) #$output))) - (mlet %store-monad ((bashrc (text-file "bashrc" "\ -# Allow non-login shells such as an xterm to get things right. -test -f /etc/profile && source /etc/profile\n")) + (mlet %store-monad ((bash-profile (text-file "bash_profile" "\ +# honor ~/.bashrc if the shell is interactive +[[ $- == *i* ]] && source ~/.bashrc + +# load system-wide environment varibales +source /etc/environment + +# common varibales for user profile +export PATH=$HOME/.guix-profile/bin:$HOME/.guix-profile/sbin:$PATH +export INFOPATH=$HOME/.guix-profile/share/info:$INFOPATH\n")) + (bashrc (text-file "bashrc" "\ +PS1='\\u@\\h \\w\\$ ' +alias ls='ls -p --color' +alias ll='ls -l'\n")) (guile-wm (gexp->derivation "guile-wm" copy-guile-wm #:modules '((guix build utils)))) @@ -128,6 +139,7 @@ XTerm*metaSendsEscape: true\n")) # Tell GDB where to look for separate debugging files. set debug-file-directory ~/.guix-profile/lib/debug\n"))) (return `((".bashrc" ,bashrc) + (".bash_profile" ,bash-profile) (".Xdefaults" ,xdefaults) (".guile-wm" ,guile-wm) (".gdbinit" ,gdbinit))))) -- 2.1.2 --=-=-= Content-Type: text/plain It only work when just one mingeety-service is enabled. Why :? --=-=-=--