From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?UTF-8?q?=E5=AE=8B=E6=96=87=E6=AD=A6?= Subject: [PATCH 1/3] services: Add 'session-environment-service'. Date: Wed, 2 Dec 2015 21:38:29 +0800 Message-ID: <1449063511-689-1-git-send-email-iyzsong@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:38695) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a47cR-00041X-UX for guix-devel@gnu.org; Wed, 02 Dec 2015 08:38:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a47cO-0000gy-Ni for guix-devel@gnu.org; Wed, 02 Dec 2015 08:38:51 -0500 Received: from mail2.openmailbox.org ([62.4.1.33]:58108) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a47cO-0000gY-Hd for guix-devel@gnu.org; Wed, 02 Dec 2015 08:38:48 -0500 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: guix-devel@gnu.org Cc: =?UTF-8?q?=E5=AE=8B=E6=96=87=E6=AD=A6?= * 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 =C2=A9 2013, 2014, 2015 Ludovic Court=C3=A8s ;;; Copyright =C2=A9 2015 Alex Kost ;;; Copyright =C2=A9 2015 Mark H Weaver +;;; Copyright =C2=A9 2015 Sou Bunnbu ;;; ;;; 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." =20 =0C ;;; +;;; 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) "=3D" (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 b= e 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)) + +=0C +;;; ;;; Console & co. ;;; =20 --=20 2.5.0