From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id 4KxULQ8EKWHB2QAAgWs5BA (envelope-from ) for ; Fri, 27 Aug 2021 17:26:07 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id 6IjZKA8EKWFYCQAAbx9fmQ (envelope-from ) for ; Fri, 27 Aug 2021 15:26:07 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 16F5F12A09 for ; Fri, 27 Aug 2021 17:26:07 +0200 (CEST) Received: from localhost ([::1]:54730 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mJdk6-0001rO-5m for larch@yhetil.org; Fri, 27 Aug 2021 11:26:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59698) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJdk2-0001rE-3H for guix-patches@gnu.org; Fri, 27 Aug 2021 11:26:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:41209) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mJdk1-0008I3-Rx for guix-patches@gnu.org; Fri, 27 Aug 2021 11:26:01 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mJdk1-00017J-P7 for guix-patches@gnu.org; Fri, 27 Aug 2021 11:26:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#50208] [PATCH 3/5] home-services: Add shells. Resent-From: Andrew Tropin Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 27 Aug 2021 15:26:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 50208 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Oleg Pykhalov Cc: 50208@debbugs.gnu.org Received: via spool by 50208-submit@debbugs.gnu.org id=B50208.16300779534279 (code B ref 50208); Fri, 27 Aug 2021 15:26:01 +0000 Received: (at 50208) by debbugs.gnu.org; 27 Aug 2021 15:25:53 +0000 Received: from localhost ([127.0.0.1]:52755 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mJdjo-00016r-MN for submit@debbugs.gnu.org; Fri, 27 Aug 2021 11:25:53 -0400 Received: from mail-lf1-f43.google.com ([209.85.167.43]:35677) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mJdjm-00016b-GA for 50208@debbugs.gnu.org; Fri, 27 Aug 2021 11:25:48 -0400 Received: by mail-lf1-f43.google.com with SMTP id l2so7029446lfp.2 for <50208@debbugs.gnu.org>; Fri, 27 Aug 2021 08:25:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=trop-in.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:in-reply-to:references:date:message-id :mime-version; bh=f6Ra0gXahhwKnl4w16TBQd2ksB3xd3u4fe6q/b1SOd8=; b=onaoqz9bfIUo53vi9LCXDDTVgSwT10/b7ZF/NI9jHwqbYa8AFbqS8VNTTXIskGh2Ef GAYS+r7TJq9wx6qIhR4hnMkJr0Vy8kyYHRsuZXR6jzVOcCYfBwKiVNSeLvDtOUDKJsGM EhUYdhPbm3EYhC0AmYkYaHOoW9G0OupadEsmOV44SnZXX56PrXaCpECCikwF9I3JgKZo Sp/kirLNTTIwGpyap/b2oj5D+3c5sR1tRFhivNYYJMzCEMotQ2a6FdSK1aGwL/qoCYoJ 6fymsDGwjBxht7tklMZmvf1EfhvemU6sx3FSGdboFPEvWqTGyzNSJYMBl2v5B662dX8e aLlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=f6Ra0gXahhwKnl4w16TBQd2ksB3xd3u4fe6q/b1SOd8=; b=bapYKP8l0/AG0vZIERMzRzhx7tUl79nKpoiQedPnp/Wel563mf7k+GpDE9P21q9Mc/ UmktGgzzcqVvcCoor8l/fxbo0fSGsU4CBADlO/8vJmSUBVNjJuDbAy1xAkwBiOas87m2 TugA936EHkSWjBSATz1MulQuBsHhGc+tUGs8YLhffU//Q9LLplHtqrF/I1x5B/COeSH7 pZ4JKtyJHf7qX0tSQLj2wNM2KDBYzSx71cLN2StT+s/O7Cdsv401z4cuQd3ZIzUBoukt OOZgbu1Gn3CmFr1bDk/Oz3iyrZ/YDwMWwheOe6bNJVe/7MIUuMaRJlZoLqHp6hwFnboB wY1w== X-Gm-Message-State: AOAM531rilMHfSSywzMjQBJMs1L5EF9MmALiSMVh4KR5sSNk7Z8uC7Bd RtPeq6Cu4VhRIZzZcoa3iXBPcw== X-Google-Smtp-Source: ABdhPJwfBb2ViVvkyEdPyvPoGRTkJ0A/jOATGjNr94rWcySpYjS8PVY3YfK3kF3/g6c5zJ0m8xxOkA== X-Received: by 2002:a05:6512:6cd:: with SMTP id u13mr7117253lff.184.1630077940081; Fri, 27 Aug 2021 08:25:40 -0700 (PDT) Received: from localhost (109-252-93-92.nat.spd-mgts.ru. [109.252.93.92]) by smtp.gmail.com with ESMTPSA id x13sm205975lfq.262.2021.08.27.08.25.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Aug 2021 08:25:39 -0700 (PDT) From: Andrew Tropin In-Reply-To: <87r1efe5eh.fsf@trop.in> References: <87bl5kbsk8.fsf@trop.in> <87r1eg8obm.fsf@gmail.com> <871r6ffklu.fsf@trop.in> <87r1efe5eh.fsf@trop.in> Date: Fri, 27 Aug 2021 18:25:36 +0300 Message-ID: <874kbadi4v.fsf@trop.in> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1630077967; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:resent-cc:resent-from:resent-sender: resent-message-id:in-reply-to:in-reply-to:references:references: list-id:list-help:list-unsubscribe:list-subscribe:list-post: dkim-signature; bh=4XcunWC7a1NDza2MhOIAvFmt8ktnDelALZXFGm4VhXY=; b=XeLALu7VlPm31e9T4VnTtCls8KEPSSzirMOucVManFXoKfcfjF6A+wb/OSRGvhf2J6r6o3 rvoP0pzaVzB5gAZf2kImYP1zP7jZeXkSxsjp6LF+0GT1S+g7PFtqeFyelDyjdM2pJc1LBj Suc6sqWBkJS4DMoXEV2hD9zF9CXTtROsSG9eNcaBjIFApZNk0CcI1c4VNA7NFhQ4Tr6xLP TfUIPrh8eFNSIOS0Po0c1w4PsRvWyizquhVZ9l46WkTKknAtkcBRk1ePnCHTpHh8AqYL0k CKFivHQLUmXKAoQhcDv4V0RFw6mXl3qrkA0BM2aT0LtCoIAIN7XlnAAYaI1kgg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1630077967; a=rsa-sha256; cv=none; b=qTDstTMjfgdMnHeBL1C8OnfZ8KzmjC9koinMO+OvPbJLJfN6fKpSi9Zdl6SJ4Cjlj+QMsd BNWlSNlw5piK2FDWOffqwFLDrMoDo/Z9f5Dt1+Lh+7PLe8eN/VRli/hUqzWDD0KdXrOx0q xBOEAjxmmuiZwMUMD1Du7FwcuHZBzXn+ASV4OOnjiaqYrRXqva0KdtTpFJFDlnstaI3Vqu D34okH6A2Ve2ziQtZa35CJVqJN+ustfg2c0n5CVSoiZMbQDy1qW5WnRCUv4dqmaT4sH7wq 5AxAVzCVVmXvmYP65P+1yeaaN4S76gPh497z1knbhjoVgTFQaMgWLdj7n8IYhg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=trop-in.20150623.gappssmtp.com header.s=20150623 header.b=onaoqz9b; dmarc=none; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Spam-Score: -3.53 Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=trop-in.20150623.gappssmtp.com header.s=20150623 header.b=onaoqz9b; dmarc=none; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Queue-Id: 16F5F12A09 X-Spam-Score: -3.53 X-Migadu-Scanner: scn0.migadu.com X-TUID: xs59oCxGKxtG --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 2021-08-27 10:03, Andrew Tropin wrote: > * gnu/home-services/shells.scm > (home-shell-profile-service-type, home-shell-profile-configuration) > (home-bash-service-type, home-bash-configuration, home-bash-extension) > (home-zsh-service-type, home-zsh-configuration, home-zsh-extension) > (home-fish-service-type, home-fish-configuration, home-fish-extension): N= ew > variables. > * gnu/local.mk (GNU_SYSTEM_MODULES): Add home-services/shells.scm. > --- > gnu/home-services/shells.scm | 637 +++++++++++++++++++++++++++++++++++ > gnu/local.mk | 1 + > 2 files changed, 638 insertions(+) > create mode 100644 gnu/home-services/shells.scm > > diff --git a/gnu/home-services/shells.scm b/gnu/home-services/shells.scm > new file mode 100644 > index 0000000000..0643019361 > --- /dev/null > +++ b/gnu/home-services/shells.scm > @@ -0,0 +1,637 @@ > +;;; GNU Guix --- Functional package management for GNU > +;;; Copyright =C2=A9 2021 Andrew Tropin > +;;; Copyright =C2=A9 2021 Xinglu Chen > +;;; > +;;; This file is part of GNU Guix. > +;;; > +;;; GNU Guix is free software; you can redistribute it and/or modify it > +;;; under the terms of the GNU General Public License as published by > +;;; the Free Software Foundation; either version 3 of the License, or (at > +;;; your option) any later version. > +;;; > +;;; GNU Guix is distributed in the hope that it will be useful, but > +;;; WITHOUT ANY WARRANTY; without even the implied warranty of > +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > +;;; GNU General Public License for more details. > +;;; > +;;; You should have received a copy of the GNU General Public License > +;;; along with GNU Guix. If not, see . > + > +(define-module (gnu home-services shells) > + #:use-module (gnu services configuration) > + #:use-module (gnu home-services configuration) > + #:use-module (gnu home-services) > + #:use-module (gnu packages shells) > + #:use-module (gnu packages bash) > + #:use-module (guix gexp) > + #:use-module (guix packages) > + #:use-module (srfi srfi-1) > + #:use-module (srfi srfi-26) > + #:use-module (ice-9 match) > + > + #:export (home-shell-profile-service-type > + home-shell-profile-configuration > + > + home-bash-service-type > + home-bash-configuration > + home-bash-extension > + > + home-zsh-service-type > + home-zsh-configuration > + home-zsh-extension > + > + home-fish-service-type > + home-fish-configuration > + home-fish-extension)) > + > +;;; Commentary: > +;;; > +;;; This module contains shell related services like Zsh. > +;;; > +;;; Code: > + > + > +;;; > +;;; Shell profile. > +;;; > + > +(define path? string?) > +(define (serialize-path field-name val) val) > + > +(define-configuration home-shell-profile-configuration > + (profile > + (text-config '()) > + "\ > +@code{home-shell-profile} is instantiated automatically by > +@code{home-environment}, DO NOT create this service manually, it can > +only be extended. > + > +@code{profile} is a list of strings or gexps, which will go to > +@file{~/.profile}. By default @file{~/.profile} contains the > +initialization code, which have to be evaluated by login shell to make > +home-environment's profile avaliable to the user, but other commands > +can be added to the file if it is really necessary. > + > +In most cases shell's configuration files are preferred places for > +user's customizations. Extend home-shell-profile service only if you > +really know what you do.")) > + > +(define (add-shell-profile-file config) > + `(("profile" > + ,(mixed-text-file > + "shell-profile" > + "\ > +HOME_ENVIRONMENT=3D$HOME/.guix-home > +. $HOME_ENVIRONMENT/setup-environment > +$HOME_ENVIRONMENT/on-first-login\n" > + (serialize-configuration > + config > + (filter-configuration-fields > + home-shell-profile-configuration-fields '(profile))))))) > + > +(define (add-profile-extensions config extensions) > + (home-shell-profile-configuration > + (inherit config) > + (profile > + (append (home-shell-profile-configuration-profile config) > + extensions)))) > + > +(define home-shell-profile-service-type > + (service-type (name 'home-shell-profile) > + (extensions > + (list (service-extension > + home-files-service-type > + add-shell-profile-file))) > + (compose concatenate) > + (extend add-profile-extensions) > + (default-value (home-shell-profile-configuration)) > + (description "Create @file{~/.profile}, which is used > +for environment initialization of POSIX compliant login shells. This > +service type can be extended with a list of strings or gexps."))) > + > +(define (serialize-boolean field-name val) "") > +(define (serialize-posix-env-vars field-name val) > + #~(string-append > + #$@(map > + (match-lambda > + ((key . #f) > + "") > + ((key . #t) > + #~(string-append "export " #$key "\n")) > + ((key . value) > + #~(string-append "export " #$key "=3D" #$value "\n"))) > + val))) > + > + > +;;; > +;;; Zsh. > +;;; > + > +(define-configuration home-zsh-configuration > + (package > + (package zsh) > + "The Zsh package to use.") > + (xdg-flavor? > + (boolean #t) > + "Place all the configs to @file{$XDG_CONFIG_HOME/zsh}. Makes > +@file{~/.zshenv} to set @env{ZDOTDIR} to @file{$XDG_CONFIG_HOME/zsh}. > +Shell startup process will continue with > +@file{$XDG_CONFIG_HOME/zsh/.zshenv}.") > + (environment-variables > + (alist '()) > + "Association list of environment variables to set for the Zsh session= ." > + serialize-posix-env-vars) > + (zshenv > + (text-config '()) > + "List of strings or gexps, which will be added to @file{.zshenv}. > +Used for setting user's shell environment variables. Must not contain > +commands assuming the presence of tty or producing output. Will be > +read always. Will be read before any other file in @env{ZDOTDIR}.") > + (zprofile > + (text-config '()) > + "List of strings or gexps, which will be added to @file{.zprofile}. > +Used for executing user's commands at start of login shell (In most > +cases the shell started on tty just after login). Will be read before > +@file{.zlogin}.") > + (zshrc > + (text-config '()) > + "List of strings or gexps, which will be added to @file{.zshrc}. > +Used for executing user's commands at start of interactive shell (The > +shell for interactive usage started by typing @code{zsh} or by > +terminal app or any other program).") > + (zlogin > + (text-config '()) > + "List of strings or gexps, which will be added to @file{.zlogin}. > +Used for executing user's commands at the end of starting process of > +login shell.") > + (zlogout > + (text-config '()) > + "List of strings or gexps, which will be added to @file{.zlogout}. > +Used for executing user's commands at the exit of login shell. It > +won't be read in some cases (if the shell terminates by exec'ing > +another process for example).")) > + > +(define (add-zsh-configuration config) > + (let* ((xdg-flavor? (home-zsh-configuration-xdg-flavor? config))) > + > + (define prefix-file > + (cut string-append > + (if xdg-flavor? > + "config/zsh/." > + "") <>)) > + > + (define (filter-fields field) > + (filter-configuration-fields home-zsh-configuration-fields > + (list field))) > + > + (define (serialize-field field) > + (serialize-configuration > + config > + (filter-fields field))) > + > + (define (file-if-not-empty field) > + (let ((file-name (symbol->string field)) > + (field-obj (car (filter-fields field)))) > + (if (not (null? ((configuration-field-getter field-obj) config))) > + `(,(prefix-file file-name) > + ,(mixed-text-file > + file-name > + (serialize-field field))) > + '()))) > + > + (filter > + (compose not null?) > + `(,(if xdg-flavor? > + `("zshenv" > + ,(mixed-text-file > + "auxiliary-zshenv" > + (if xdg-flavor? > + "source ${XDG_CONFIG_HOME:-$HOME/.config}/zsh/.zshen= v\n" > + ""))) > + '()) > + (,(prefix-file "zshenv") > + ,(mixed-text-file > + "zshenv" > + (if xdg-flavor? > + "export ZDOTDIR=3D${XDG_CONFIG_HOME:-$HOME/.config}/zsh\n" > + "") > + (serialize-field 'zshenv) > + (serialize-field 'environment-variables))) > + (,(prefix-file "zprofile") > + ,(mixed-text-file > + "zprofile" > + "\ > +# Setups system and user profiles and related variables > +source /etc/profile > +# Setups home environment profile > +source ~/.profile > + > +# It's only necessary if zsh is a login shell, otherwise profiles will > +# be already sourced by bash > +" > + (serialize-field 'zprofile))) > + > + ,@(list (file-if-not-empty 'zshrc) > + (file-if-not-empty 'zlogin) > + (file-if-not-empty 'zlogout)))))) > + > +(define (add-zsh-packages config) > + (list (home-zsh-configuration-package config))) > + > +(define-configuration/no-serialization home-zsh-extension > + (environment-variables > + (alist '()) > + "Association list of environment variables to set.") > + (zshrc > + (text-config '()) > + "List of strings or gexps.") > + (zshenv > + (text-config '()) > + "List of strings or gexps.") > + (zprofile > + (text-config '()) > + "List of strings or gexps.") > + (zlogin > + (text-config '()) > + "List of strings or gexps.") > + (zlogout > + (text-config '()) > + "List of strings or gexps.")) > + > +(define (home-zsh-extensions original-config extension-configs) > + (home-zsh-configuration > + (inherit original-config) > + (environment-variables > + (append (home-zsh-configuration-environment-variables original-confi= g) > + (append-map > + home-zsh-extension-environment-variables extension-configs)= )) > + (zshrc > + (append (home-zsh-configuration-zshrc original-config) > + (append-map > + home-zsh-extension-zshrc extension-configs))) > + (zshenv > + (append (home-zsh-configuration-zshenv original-config) > + (append-map > + home-zsh-extension-zshenv extension-configs))) > + (zprofile > + (append (home-zsh-configuration-zprofile original-config) > + (append-map > + home-zsh-extension-zprofile extension-configs))) > + (zlogin > + (append (home-zsh-configuration-zlogin original-config) > + (append-map > + home-zsh-extension-zlogin extension-configs))) > + (zlogout > + (append (home-zsh-configuration-zlogout original-config) > + (append-map > + home-zsh-extension-zlogout extension-configs))))) > + > +(define home-zsh-service-type > + (service-type (name 'home-zsh) > + (extensions > + (list (service-extension > + home-files-service-type > + add-zsh-configuration) > + (service-extension > + home-profile-service-type > + add-zsh-packages))) > + (compose identity) > + (extend home-zsh-extensions) > + (default-value (home-zsh-configuration)) > + (description "Install and configure Zsh."))) > + > + > +;;; > +;;; Bash. > +;;; > + > +(define-configuration home-bash-configuration > + (package > + (package bash) > + "The Bash package to use.") > + (guix-defaults? > + (boolean #t) > + "Add sane defaults like reading @file{/etc/bashrc}, coloring output > +for @code{ls} provided by guix to @file{.bashrc}.") > + (environment-variables > + (alist '()) > + "Association list of environment variables to set for the Bash sessio= n." > + serialize-posix-env-vars) > + (bash-profile > + (text-config '()) > + "List of strings or gexps, which will be added to @file{.bash_profile= }. > +Used for executing user's commands at start of login shell (In most > +cases the shell started on tty just after login). @file{.bash_login} > +won't be ever read, because @file{.bash_profile} always present.") > + (bashrc > + (text-config '()) > + "List of strings or gexps, which will be added to @file{.bashrc}. > +Used for executing user's commands at start of interactive shell (The > +shell for interactive usage started by typing @code{bash} or by > +terminal app or any other program).") > + (bash-logout > + (text-config '()) > + "List of strings or gexps, which will be added to @file{.bash_logout}. > +Used for executing user's commands at the exit of login shell. It > +won't be read in some cases (if the shell terminates by exec'ing > +another process for example).")) > + > +;; TODO: Use value from (gnu system shadow) > +(define guix-bashrc > + "\ > +# Bash initialization for interactive non-login shells and > +# for remote shells (info \"(bash) Bash Startup Files\"). > + > +# Export 'SHELL' to child processes. Programs such as 'screen' > +# honor it and otherwise use /bin/sh. > +export SHELL > + > +if [[ $- !=3D *i* ]] > +then > + # We are being invoked from a non-interactive shell. If this > + # is an SSH session (as in \"ssh host command\"), source > + # /etc/profile so we get PATH and other essential variables. > + [[ -n \"$SSH_CLIENT\" ]] && source /etc/profile > + > + # Don't do anything else. > + return > +fi > + > +# Source the system-wide file. > +source /etc/bashrc > + > +# Adjust the prompt depending on whether we're in 'guix environment'. > +if [ -n \"$GUIX_ENVIRONMENT\" ] > +then > + PS1=3D'\\u@\\h \\w [env]\\$ ' > +else > + PS1=3D'\\u@\\h \\w\\$ ' > +fi > +alias ls=3D'ls -p --color=3Dauto' > +alias ll=3D'ls -l' > +alias grep=3D'grep --color=3Dauto'\n") > + > +(define (add-bash-configuration config) > + (define (filter-fields field) > + (filter-configuration-fields home-bash-configuration-fields > + (list field))) > + > + (define (serialize-field field) > + (serialize-configuration > + config > + (filter-fields field))) > + > + (define* (file-if-not-empty field #:optional (extra-content #f)) > + (let ((file-name (symbol->string field)) > + (field-obj (car (filter-fields field)))) > + (if (or extra-content > + (not (null? ((configuration-field-getter field-obj) config= )))) > + `(,(object->snake-case-string file-name) Didn't add object->snake-case-string function to this patch series, will add it in v2. > + ,(mixed-text-file > + (object->snake-case-string file-name) > + (if extra-content extra-content "") > + (serialize-field field))) > + '()))) > + > + (filter > + (compose not null?) > + `(("bash_profile" > + ,(mixed-text-file > + "bash_profile" > + "\ > +# Setups system and user profiles and related variables > +# /etc/profile will be sourced by bash automatically > +# Setups home environment profile > +if [ -f ~/.profile ]; then source ~/.profile; fi > + > +# Honor per-interactive-shell startup file > +if [ -f ~/.bashrc ]; then source ~/.bashrc; fi > +" > + (serialize-field 'bash-profile) > + (serialize-field 'environment-variables))) > + > + ,@(list (file-if-not-empty > + 'bashrc > + (if (home-bash-configuration-guix-defaults? config) > + guix-bashrc > + #f)) > + (file-if-not-empty 'bash-logout))))) > + > +(define (add-bash-packages config) > + (list (home-bash-configuration-package config))) > + > +(define-configuration/no-serialization home-bash-extension > + (environment-variables > + (alist '()) > + "Association list of environment variables to set.") > + (bash-profile > + (text-config '()) > + "List of strings or gexps.") > + (bashrc > + (text-config '()) > + "List of strings or gexps.") > + (bash-logout > + (text-config '()) > + "List of strings or gexps.")) > + > +(define (home-bash-extensions original-config extension-configs) > + (home-bash-configuration > + (inherit original-config) > + (environment-variables > + (append (home-bash-configuration-environment-variables original-conf= ig) > + (append-map > + home-bash-extension-environment-variables extension-configs= ))) > + (bash-profile > + (append (home-bash-configuration-bash-profile original-config) > + (append-map > + home-bash-extension-bash-profile extension-configs))) > + (bashrc > + (append (home-bash-configuration-bashrc original-config) > + (append-map > + home-bash-extension-bashrc extension-configs))) > + (bash-logout > + (append (home-bash-configuration-bash-logout original-config) > + (append-map > + home-bash-extension-bash-logout extension-configs))))) > + > +(define home-bash-service-type > + (service-type (name 'home-bash) > + (extensions > + (list (service-extension > + home-files-service-type > + add-bash-configuration) > + (service-extension > + home-profile-service-type > + add-bash-packages))) > + (compose identity) > + (extend home-bash-extensions) > + (default-value (home-bash-configuration)) > + (description "Install and configure GNU Bash."))) > + > + > +;;; > +;;; Fish. > +;;; > + > +(define (serialize-fish-aliases field-name val) > + #~(string-append > + #$@(map (match-lambda > + ((key . value) > + #~(string-append "alias " #$key " \"" #$value "\"\n")) > + (_ "")) > + val))) > + > +(define (serialize-fish-abbreviations field-name val) > + #~(string-append > + #$@(map (match-lambda > + ((key . value) > + #~(string-append "abbr --add " #$key " " #$value "\n")) > + (_ "")) > + val))) > + > +(define (serialize-fish-env-vars field-name val) > + #~(string-append > + #$@(map (match-lambda > + ((key . #f) > + "") > + ((key . #t) > + #~(string-append "set " #$key "\n")) > + ((key . value) > + #~(string-append "set " #$key " " #$value "\n"))) > + val))) > + > +(define-configuration home-fish-configuration > + (package > + (package fish) > + "The Fish package to use.") > + (config > + (text-config '()) > + "List of strings or gexps, which will be added to > +@file{$XDG_CONFIG_HOME/fish/config.fish}.") > + (environment-variables > + (alist '()) > + "Association list of environment variables to set in Fish." > + serialize-fish-env-vars) > + (aliases > + (alist '()) > + "Association list of aliases for Fish, both the key and the value > +should be a string. An alias is just a simple function that wraps a > +command, If you want something more akin to @dfn{aliases} in POSIX > +shells, see the @code{abbreviations} field." > + serialize-fish-aliases) > + (abbreviations > + (alist '()) > + "Association list of abbreviations for Fish. These are words that, > +when typed in the shell, will automatically expand to the full text." > + serialize-fish-abbreviations)) > + > +(define (fish-files-service config) > + `(("config/fish/config.fish" > + ,(mixed-text-file > + "fish-config.fish" > + #~(string-append "\ > +# if we haven't sourced the login config, do it > +status --is-login; and not set -q __fish_login_config_sourced > +and begin > + > + set --prepend fish_function_path " > + #$fish-foreign-env > + "/share/fish/functions > + fenv source $HOME/.profile > + set -e fish_function_path[1] > + > + set -g __fish_login_config_sourced 1 > + > +end\n\n") > + (serialize-configuration > + config > + home-fish-configuration-fields))))) > + > +(define (fish-profile-service config) > + (list (home-fish-configuration-package config))) > + > +(define-configuration/no-serialization home-fish-extension > + (config > + (text-config '()) > + "List of strings or gexps for extending the Fish initialization file.= ") > + (environment-variables > + (alist '()) > + "Association list of environment variables to set.") > + (aliases > + (alist '()) > + "Association list of Fish aliases.") > + (abbreviations > + (alist '()) > + "Association list of Fish abbreviations.")) > + > +(define (home-fish-extensions original-config extension-configs) > + (home-fish-configuration > + (inherit original-config) > + (config > + (append (home-fish-configuration-config original-config) > + (append-map > + home-fish-extension-config extension-configs))) > + (environment-variables > + (append (home-fish-configuration-environment-variables original-conf= ig) > + (append-map > + home-fish-extension-environment-variables extension-configs= ))) > + (aliases > + (append (home-fish-configuration-aliases original-config) > + (append-map > + home-fish-extension-aliases extension-configs))) > + (abbreviations > + (append (home-fish-configuration-abbreviations original-config) > + (append-map > + home-fish-extension-abbreviations extension-configs))))) > + > +;; TODO: Support for generating completion files > +;; TODO: Support for installing plugins > +(define home-fish-service-type > + (service-type (name 'home-fish) > + (extensions > + (list (service-extension > + home-files-service-type > + fish-files-service) > + (service-extension > + home-profile-service-type > + fish-profile-service))) > + (compose identity) > + (extend home-fish-extensions) > + (default-value (home-fish-configuration)) > + (description "\ > +Install and configure Fish, the friendly interactive shell."))) > + > + > +(define (generate-home-shell-profile-documentation) > + (generate-documentation > + `((home-shell-profile-configuration > + ,home-shell-profile-configuration-fields)) > + 'home-shell-profile-configuration)) > + > +(define (generate-home-bash-documentation) > + (generate-documentation > + `((home-bash-configuration > + ,home-bash-configuration-fields)) > + 'home-bash-configuration)) > + > +(define (generate-home-zsh-documentation) > + (generate-documentation > + `((home-zsh-configuration > + ,home-zsh-configuration-fields)) > + 'home-zsh-configuration)) > + > +(define (generate-home-fish-documentation) > + (string-append > + (generate-documentation > + `((home-fish-configuration > + ,home-fish-configuration-fields)) > + 'home-fish-configuration) > + "\n\n" > + (generate-documentation > + `((home-fish-extension > + ,home-fish-extension-fields)) > + 'home-fish-extension))) > + > +;; (display (generate-home-shell-profile-documentation)) > +;; (display (generate-home-bash-documentation)) > +;; (display (generate-home-zsh-documentation)) > diff --git a/gnu/local.mk b/gnu/local.mk > index e24da4716f..dc0e732114 100644 > --- a/gnu/local.mk > +++ b/gnu/local.mk > @@ -76,6 +76,7 @@ GNU_SYSTEM_MODULES =3D \ > %D%/home-services/symlink-manager.scm \ > %D%/home-services/fontutils.scm \ > %D%/home-services/configuration.scm \ > + %D%/home-services/shells.scm \ > %D%/image.scm \ > %D%/packages.scm \ > %D%/packages/abduco.scm \ --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmEpA/AACgkQIgjSCVjB 3rCWLg//TNp7Axgv68YStSS6kPMqM1lk8rvyw8Fwge4xQayHMvCbWt9gO2FV6uH9 5uZa6kV0FIKFfE5FpiJujkwkBELR33mWfPEWMhLSS9tZnXsCoSJ/jT1yULqTt75Z QRvn1r8xZESqimUu3MU7lLrwcqFfd+VfKIWWiFjTl2dORXtsEl/pnuqJsN0wOOpp wSpYFbr18qY319gSXJG8vUeNgx1bdQFGlLDTr6z+bQCzU63HGoXP5GJGw5K1Mg21 hMVQKdqoUuGUqKuBri45JpMjGPFBYuZkOyObS6LNEDPPsYHfN2X4gPGouuKDdPWJ NlvCNeAK9Z7bpUYzBCkGua7N/VZfQVn51gD21PMzthmNNKKxPz+TkQjuXpCDjPJw XKMmvOgn9yfr1jotIiH1M0z8Lvynj+XPXuV8NC+6hyZ4pqn0a4AzbnvYG2klpkN+ lV6+95UhvWRgrXXYbZRR/McEHC2sNAjrflVGNaIW1wL/daCaqZFw31Qenxf5k8sw 2FuR86fRqdprjaUpZUNxebTgf5cNwTR7+SCogk2GPz+a9NeO0jIASE/x07VA4YS8 msIR+J5vYPvA+W9UR8pvz0eqtNF3mvYmRhjmB22iDwbhY5AVsXVSXJ2xWtzrtdgC GufLG2ZapTi48ppVPn/l5hLU35uLlSFd0WjIexG8nv0F9nVo3P0= =fRhY -----END PGP SIGNATURE----- --=-=-=--