From: 宋文武 <iyzsong@gmail.com>
To: "Ludovic Courtès" <ludo@gnu.org>
Cc: guix-devel@gnu.org
Subject: Re: use zsh as login shell
Date: Tue, 02 Dec 2014 22:43:20 +0800 [thread overview]
Message-ID: <87wq6aun7b.fsf@gmail.com> (raw)
In-Reply-To: <87egsjcyst.fsf@gnu.org>
[-- Attachment #1: Type: text/plain, Size: 1923 bytes --]
Ludovic Courtès <ludo@gnu.org> writes:
> 宋文武 <iyzsong@gmail.com> skribis:
>
>> Ludovic Courtès <ludo@gnu.org> writes:
>>
>>> 宋文武 <iyzsong@gmail.com> skribis:
>>>
>>>> Ludovic Courtès <ludo@gnu.org> 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=VAL file, with no
>> support for varibales substitute. If we do not use pam_env (linux specified?),
>> 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 ‘export foo=bar’ work
> for zsh?
It does.
>
> If it does, let’s 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.
>
> It’s OK to have a 2-KiB /etc/zlogin, even when one doesn’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’.
And this is what I have so far:
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-gnu-Add-etc-environment.patch --]
[-- Type: text/x-patch, Size: 8033 bytes --]
From 1e400957b29a47f63548df39b36a7c0f1d8a37d9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=AE=8B=E6=96=87=E6=AD=A6?= <iyzsong@gmail.com>
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 <http://www.linux-pam.org/Linux-PAM-html/sag-configuration-example.html>.
(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
[-- Attachment #3: Type: text/plain, Size: 64 bytes --]
It only work when just one mingeety-service is enabled. Why :?
next prev parent reply other threads:[~2014-12-02 14:43 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-27 15:58 use zsh as login shell 宋文武
2014-11-27 20:15 ` Ludovic Courtès
2014-11-28 15:06 ` 宋文武
2014-11-28 22:26 ` Ludovic Courtès
2014-11-29 3:24 ` 宋文武
2014-12-01 12:57 ` Ludovic Courtès
2014-12-02 14:43 ` 宋文武 [this message]
2014-12-04 23:10 ` Ludovic Courtès
2014-12-05 5:11 ` Mark H Weaver
2014-12-05 18:54 ` Ludovic Courtès
2014-12-05 11:21 ` 宋文武
2014-12-06 8:04 ` use zsh and fish " 宋文武
2014-12-06 15:09 ` Ludovic Courtès
2014-11-28 15:11 ` use zsh " 宋文武
2014-12-05 13:57 ` 宋文武
2014-12-06 22:35 ` /etc/profile and .zshrc skeleton Ludovic Courtès
2014-12-07 4:06 ` 宋文武
2014-12-07 20:35 ` Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87wq6aun7b.fsf@gmail.com \
--to=iyzsong@gmail.com \
--cc=guix-devel@gnu.org \
--cc=ludo@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.