all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [PATCH 1/3] services: Add 'session-environment-service'.
@ 2015-12-02 13:38 宋文武
  2015-12-02 13:38 ` [PATCH 2/3] system: Add /etc/environment 宋文武
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: 宋文武 @ 2015-12-02 13:38 UTC (permalink / raw)
  To: guix-devel; +Cc: 宋文武

* gnu/services/base.scm (session-environment-service): New procedure.
(session-environment-service-type): New variable.
(environment-variables->environment-file): New procedure.
---
 gnu/services/base.scm | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/gnu/services/base.scm b/gnu/services/base.scm
index c242c7d..d599c52 100644
--- a/gnu/services/base.scm
+++ b/gnu/services/base.scm
@@ -2,6 +2,7 @@
 ;;; Copyright © 2013, 2014, 2015 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2015 Alex Kost <alezost@gmail.com>
 ;;; Copyright © 2015 Mark H Weaver <mhw@netris.org>
+;;; Copyright © 2015 Sou Bunnbu <iyzsong@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -48,6 +49,8 @@
             device-mapping-service
             swap-service
             user-processes-service
+            session-environment-service
+            session-environment-service-type
             host-name-service
             console-keymap-service
             console-font-service
@@ -368,6 +371,36 @@ stopped before 'kill' is called."
 
 \f
 ;;;
+;;; System-wide environment variables.
+;;;
+
+(define (environment-variables->environment-file vars)
+  "Return a file for pam_env(8) that contains environment variables VARS."
+  (apply mixed-text-file "environment"
+         (fold-right (lambda (pair result)
+                       (cons* (car pair) "=" (cdr pair) "\n" result))
+                     '() vars)))
+
+(define session-environment-service-type
+  (service-type
+   (name 'session-environment)
+   (extensions
+    (list (service-extension
+           etc-service-type
+           (lambda (vars)
+             (list `("environment"
+                     ,(environment-variables->environment-file vars)))))))))
+
+(define (session-environment-service vars)
+  "Return a service that builds the @file{/etc/environment}, which can be read
+by PAM-aware applications to set environment variables for sessions.
+
+VARS should be an association list in which both the keys and the values are
+strings or string-valued gexps."
+  (service session-environment-service-type vars))
+
+\f
+;;;
 ;;; Console & co.
 ;;;
 
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2015-12-05  2:55 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-02 13:38 [PATCH 1/3] services: Add 'session-environment-service' 宋文武
2015-12-02 13:38 ` [PATCH 2/3] system: Add /etc/environment 宋文武
2015-12-04 14:33   ` Ludovic Courtès
2015-12-05  2:55     ` 宋文武
2015-12-02 13:38 ` [PATCH 3/3] system: pam: Honor /etc/environment 宋文武
2015-12-04 14:38   ` Ludovic Courtès
2015-12-02 18:45 ` [PATCH 1/3] services: Add 'session-environment-service' Alex Kost
2015-12-03 11:59   ` 宋文武
2015-12-04 14:29     ` Ludovic Courtès

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.