From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id 4JFvChMELGJcBwAAgWs5BA (envelope-from ) for ; Sat, 12 Mar 2022 03:23:15 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id wC+uBxMELGLL3QAA9RJhRA (envelope-from ) for ; Sat, 12 Mar 2022 03:23:15 +0100 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 9290D2A912 for ; Sat, 12 Mar 2022 03:23:14 +0100 (CET) Received: from localhost ([::1]:37130 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nSrPV-000141-Pf for larch@yhetil.org; Fri, 11 Mar 2022 21:23:13 -0500 Received: from eggs.gnu.org ([209.51.188.92]:47156) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSrPK-00013n-5R for guix-patches@gnu.org; Fri, 11 Mar 2022 21:23:02 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:44988) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nSrPJ-0007mr-TU for guix-patches@gnu.org; Fri, 11 Mar 2022 21:23:01 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nSrPJ-00056P-Q7 for guix-patches@gnu.org; Fri, 11 Mar 2022 21:23:01 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#54293] [PATCH v2] home: Add home-git-service-type. References: In-Reply-To: Resent-From: iyzsong@outlook.com Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 12 Mar 2022 02:23:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 54293 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: To: 54293@debbugs.gnu.org Cc: =?UTF-8?Q?=E5=AE=8B=E6=96=87=E6=AD=A6?= Received: via spool by 54293-submit@debbugs.gnu.org id=B54293.164705178019605 (code B ref 54293); Sat, 12 Mar 2022 02:23:01 +0000 Received: (at 54293) by debbugs.gnu.org; 12 Mar 2022 02:23:00 +0000 Received: from localhost ([127.0.0.1]:38885 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nSrP9-000561-SV for submit@debbugs.gnu.org; Fri, 11 Mar 2022 21:23:00 -0500 Received: from mail-tycjpn01olkn2099.outbound.protection.outlook.com ([40.92.99.99]:11956 helo=JPN01-TYC-obe.outbound.protection.outlook.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nSrP4-00055i-M4 for 54293@debbugs.gnu.org; Fri, 11 Mar 2022 21:22:50 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JBVLO+RqJa2rqLgMiX6gx6hkmZf6CGymTRVGEWae/G2KfYlSITpkh+WFaTN57S0iX+hoFnqX+botWL69Qhpm/zIx4qyaTOeYZPsum3tjFHLgAvUwo3LY+dbpctbB+BLBmFO+EorXUvP773SaCAp0iwWZiepW05PvEN7UMZ+j6m4eTh1i8hwUI2pFdCvWSAfy/6ya/CBieMWsoacwrh4dyH9W9zGRuzU/DS1pZo74ydabPvlZhrzMdGrqggAh8QyC20fyxKiyVK0ZFaMOnTqFLlEDClYC2kkKYKkfzX2ZYQFkmOHKeGPCiiJhCCH4/Jq6QbUoAWrR5w9F/gRzV1Kubw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=xiEctsXhuGGfYMpqOxEAAunbwksp9XNXnMLXXjrETSg=; b=Ako0UtmIl/gFksGBI+kTxYbPxJyS1kY8N8Xczwx8SVocJyAtgpcrlVfHs67nbNxyPvoBnvhUDxJlFCLYwQTKXD8bH/w3bWlK7vhg9uLJ+DNcPTSu9suwSQr7uhgl9rd9klxW9bTPf7FZdQiTnxpKGzIuaxMKygM1ybPL6Sg2qVy8r4+/waiJ4Zx1ZgwWbPrEm3lzwCQQ4mUPlUs5UXQ3ZanTr+ep3MNr4S+fZWItHHISqGUK68TqW+OAn7F9X/eZL9nIhES2EnpvuOW3T+oix6DmaY5vCkL5Q44WrZKhSUZCeUYGAby4qvwmwoLP31PGW27RFP29B+JsZKll8ssleQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xiEctsXhuGGfYMpqOxEAAunbwksp9XNXnMLXXjrETSg=; b=hticpGHMCx+3lgirGJcKFkTmN7lxW8nrtbrbKVwVfVaEFPYtvTOvsrH5SArwPt9Ivqci/9Qbs59Rhgl35sKhB7CZpMBXQpjoX/1kcJkPIvExgkY26OPnkcV4MM86g5R619qR0m7vBouuxVQP7XKAwIWLgM4odvbxzVjGhvXIG2w/++CL5hL9CMprUGyIslkr5n9xz++uEmqfjIDIh/oy07EcRrP/TMFEiEVnFrUTOIEKc4c+YZhIMoymj41v9Ag0xXPt49cPceB2KVV+62Fb2HeQCzx4NTkquEIQ1dxLxElQ0c5FDgnEFwGf4fZdP0L+piHKuCcWZatgjvh1g/M8QA== Received: from TYCP286MB1897.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:11e::13) by OSYP286MB0456.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:89::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5061.22; Sat, 12 Mar 2022 02:22:39 +0000 Received: from TYCP286MB1897.JPNP286.PROD.OUTLOOK.COM ([fe80::ec4a:85af:7fb8:de9b]) by TYCP286MB1897.JPNP286.PROD.OUTLOOK.COM ([fe80::ec4a:85af:7fb8:de9b%5]) with mapi id 15.20.5061.025; Sat, 12 Mar 2022 02:22:38 +0000 From: iyzsong@outlook.com Date: Sat, 12 Mar 2022 10:22:32 +0800 Message-ID: X-Mailer: git-send-email 2.34.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-TMN: [xMKCUqEK+wzkB9ndWRhMVyyutN5YdeNqZmSqadHUK4pqQA/jUja+5CjhWBiVW80i] X-ClientProxiedBy: HKAPR04CA0005.apcprd04.prod.outlook.com (2603:1096:203:d0::15) To TYCP286MB1897.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:11e::13) X-Microsoft-Original-Message-ID: <20220312022232.16934-1-iyzsong@member.fsf.org> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e5153cb6-dbf5-49b9-f8c4-08da03cf2db5 X-MS-TrafficTypeDiagnostic: OSYP286MB0456:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kWG/1NyIWGuF9YuA5sOpjseHv0ygTVwC9AA4jp4tPib5dWpX8jxi0QHceQGgGCS28XNQoiLdXKnd30MP9UCj37Om3FIVALuD8a6/tyc9X8UZQXx9IIAY7JualeY3ToOufjlHOlgeQkxJ53TH/R+rAix72dsHulKXcKrr6e5tIryaswAT22xjQ1MQwcNBdmeJoMqucWd1UkIrq8S/nUxNhyZYJoXJqHZoh55+Ok+Oh5y5sg3L6vDtM+8iCZfNbLeGgSgOzcasPXAPwnLq9YdaVtXeRdmlF3tKv2OiyPXmEji64DV9uf4/hDFxQf1DFBtQ0WfIKD06lsR8hBpzrNKeq9Ufneri2O3guxFLXU1NsDYu1FLe3Vqd2PB+GeCceGtvBQ3cAh+hPbJnJp+KuqKnfWUeM8xTpdjZe21yYjtpJ5uOQ6bMlgRPEUrOzV0RvoW2EUGFU/Cf00OUe7R+9dOp105efdEniNWu7Tbvnj4+R20qf+THjj/x7XFM/8bbZuxSKj3+EWirG1XVw0TP3RMa1y7HHQPIpcv7b73qjDwIVxwzRMtwWEE+FregJSdEKu4nmbnynmVj+kVTCJBNYBqD33To5pIikXfRgohukYYaOxMQMKxS2G/GvsKMk2zuTiFY X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: X6u/iT/wCA0/hCDd3DcL3pUaoqAY3u+iEwUY6ukd54IG7yjpwymA7dWZ1UotS6xOSsSC2psa0zRwrdFSZCeBcscqxXdnUWvDe5tVaNFZOSLhsV0NfggKRjjLt5P0+SqG2/8gC1Xj43mVoT++K2E4XjBOZ/akEWvIQlYCufGrIaAjjOEX7jBbtAqodhcbXAgPVAohPRsQk+clhT/QbijvyHWc3yZbSqBtwGG43O1Q+QnYnK8FSYKJO72Z5vT26ta9h8Uu1YctRjGx9fI7S2xsL7T3N4j+hXnUNIWx1N587uMDwPLrhmj28g/SKGW7pK5QAUcBTw6PZ01OwVdw/xyUFJ+CP4UyY14BeK9q5UhEoOfRQmZ5KPcrSFGTq2VOy2DhI6g9p8pHHjsZBbscJvdECRNxql+amEkf4NFTf+4MTV0xc2kzjdC8AIPH0lvLFMFmwtsdmMNFTGuOcBtWpWcAgNuxYTD4ahGE8qnxwAZ6p+BLNinbONJGROILA7uWZfuazP72fBm1yXGJtW0duWjXwqPoIcwE7Gwwh98PODPJiaOG5Yn3e4ctpUqDqFRzHSEvXIZL9PyP517Vbxl9SGsEqE5DxhDyo7YvFUjBtljS5VYARaLhCwSOg1bjQwbBazIILyoATXMjZw84ey3XJbV/4GiDY2udy/OxDuhYJdTBpiimiE4NBjb87ySxMeTynp4mckq7rAWvKTb06u/ttqZxaJpGPWjGmI5PL/Rt9ScObdI4OOvwQB9GrmJBV1SfhtxrtYSPb9FndADRsyQsZGEBWioJfZ4xrg4DyKVBhH1fv+jb+gm+ldBH2Fii3NuV1K3BppRfNe9Nq7C/BA9Q/SiqsCbdUlGGWLp/BEbj0s8MN0hxI4K0cX5spnKQgnawMwZJdKawdZjIBRLN7ElIRL2y+ZRDoYQqEcqbCBq79OocjQ8jY7DkpNRsSQ5P8m/8zoaf t0UXNkYAd2mSqKP4VI4UCJhIA8Bk9Q6HrEDNHl1WYYhjG3s7si68cVUUDTle+m+XBpyE+T7xgWm7NLq2XS9bghWteLhmRiZAUjeHt7+4kXVeFDrhYkGEYJh73hDDOE3b2zV5Ui0rkgbQffrH+lAAe2e9hnXEohz0d+N07wQ+kIYuoPh9Q2AjgtVysY7IC2zCNZvefAZbYzfVhdD+XAvm/xa8wfQpTvSWlxQlLZYAtWa9XFJvRCvJwKWy2NIW6y9OKVBog2keaSXL2BIaPvyr4w== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: e5153cb6-dbf5-49b9-f8c4-08da03cf2db5 X-MS-Exchange-CrossTenant-AuthSource: TYCP286MB1897.JPNP286.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Mar 2022 02:22:38.9484 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: OSYP286MB0456 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 X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1647051794; 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: content-transfer-encoding:content-transfer-encoding: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=xiEctsXhuGGfYMpqOxEAAunbwksp9XNXnMLXXjrETSg=; b=m3f1RP0t/kkODRUmGoFLQkI4M1thHNTu0tu4LC9entGEkvAElJjwc/ZLmFYjWpUZwlyuR2 jaUccGXa7F2AWYUE2OTnQW9txNSU2Fl6zFR2Il91k/0GGTVa7DmylKXdi72YCKHnRkBwHf Jjfx1oIS5HC3afIowWBeYc9GvqugGwtYQCS6UKKZfdL3eojZnqWu6r1Bm5pQ6BrOtY5Q4S jwOUOoR3TOKhZP3G8I5v+lfGh/tYjLIKNvOVnux+xlhke1ROXnUPG6xNzQE7uf4uV+/H0y GrALIwCKDA36sUhKGG158tKbU0jLTgPz1+tPbOJZmkQ2sivG4rUGqsLEjiaL/Q== ARC-Seal: i=2; s=key1; d=yhetil.org; t=1647051794; a=rsa-sha256; cv=fail; b=g6ErPrWU0JZp9sz2qTmpntfI6DF7FPkJVozKbSa3PR0pwKPgmAe/mjd0d7wiNL529o8N0B iGKWzK3TAbE2+12hgYHrv6qhr9Ah7V/thpllwCxg5cFRZwHVXfiJNjfvApjwggqcmXYIr7 v3CxtCSaO0tlKpdn1q0JXoGLiNiqTTfqK4mpBZ9eCAA6ThvH94MMjOej/yKpV5HfTO7jCH HO4O2iKpfg+xW6iHtwdkX/YsKaKGITKUjCA11GFoktHx3zelvCN8XWYV1b8b830Ye7zKe8 kGIDUQsjj6ObSGmNE8S+ra4HVW268ihpgKKj2rA2RD3qRaibYgaCx0x+xcHjFQ== ARC-Authentication-Results: i=2; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=outlook.com header.s=selector1 header.b=hticpGHM; arc=reject ("signature check failed: fail, {[1] = sig:microsoft.com:reject}"); dmarc=fail reason="SPF not aligned (relaxed)" header.from=outlook.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: 6.51 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=outlook.com header.s=selector1 header.b=hticpGHM; arc=reject ("signature check failed: fail, {[1] = sig:microsoft.com:reject}"); dmarc=fail reason="SPF not aligned (relaxed)" header.from=outlook.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 9290D2A912 X-Spam-Score: 6.51 X-Migadu-Scanner: scn0.migadu.com X-TUID: KvryZPcEiLYR * gnu/home/services/git.scm: New file. * gnu/local.mk (GNU_SYSTEM_MODULES): Add it. --- gnu/home/services/git.scm | 214 ++++++++++++++++++++++++++++++++++++++ gnu/local.mk | 1 + 2 files changed, 215 insertions(+) create mode 100644 gnu/home/services/git.scm diff --git a/gnu/home/services/git.scm b/gnu/home/services/git.scm new file mode 100644 index 0000000000..f39c931c38 --- /dev/null +++ b/gnu/home/services/git.scm @@ -0,0 +1,214 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2022 宋文武 +;;; +;;; 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 git) + #:use-module (gnu home services) + #:use-module (gnu services configuration) + #:use-module (gnu packages version-control) + #:use-module (guix packages) + #:use-module (guix gexp) + #:use-module (srfi srfi-1) + #:use-module (ice-9 match) + #:export (home-git-service-type + home-git-configuration)) + +(define (git-option-value? value) + (or (unspecified? value) + (string? value) + (integer? value) + (boolean? value))) + +(define (serialize-git-option-value value) + (cond + ((string? value) (with-output-to-string (lambda () (write value)))) + ((integer? value) (number->string value)) + ((boolean? value) (if value "true" "false")))) + +(define (git-options? options) + "Return #t if OPTIONS is a well-formed sexp for git options." + (define git-variable? + (match-lambda + ((key value) (and (symbol? key) (git-option-value? value))) + (_ #f))) + (every + (match-lambda + (((section subsection) variables ..1) + (and (symbol? section) + (string? subsection) + (every git-variable? variables))) + ((section variables ..1) + (and (symbol? section) + (every git-variable? variables))) + (_ #f)) + options)) + +(define (serialize-git-options options) + "Return the @command{git-config} text form for OPTIONS." + (define serialize-section + (match-lambda + ((section variables ..1) + (with-output-to-string + (lambda () + (match section + ((section subsection) + (simple-format #t "[~a ~s]~%" section subsection)) + (_ + (simple-format #t "[~a]~%" section))) + (for-each + (match-lambda + ((key value) + (simple-format #t "\t~a = ~a~%" + key (serialize-git-option-value value)))) + variables)))))) + (string-concatenate (map serialize-section options))) + +(define-configuration/no-serialization home-git-configuration + (package + (package git) + "The Git package to use.") + (enable-send-email? + (boolean #t) + "Whether to install git email tools from the package's @code{send-email} +output.") + (user.name + (git-option-value *unspecified*) + "The human-readable name used in the author and committer identity when +creating commit or tag objects, or when writing reflogs. If you need the +author or committer to be different, the @code{author.name} or +@code{committer.name} can be set.") + (user.email + (git-option-value *unspecified*) + "The email address used in the author and committer identity when creating +commit or tag objects, or when writing reflogs. If you need the author or +committer to be different, the @code{author.email} or @code{committer.email} +can be set.") + (user.signingKey + (git-option-value *unspecified*) + "If @command{git-tag} or @command{git-commit} is not selecting the key you +want it to automatically when creating a signed tag or commit, you can +override the default selection with this variable. This option is passed +unchanged to gpg’s @code{--local-user} parameter, so you may specify a key +using any method that gpg supports.") + (author.name + (git-option-value *unspecified*) + "The human-readable name used in the author identity when creating commit +or tag objects, or when writing reflogs.") + (author.email + (git-option-value *unspecified*) + "The email address used in the author identity when creating commit or tag +objects, or when writing reflogs.") + (committer.name + (git-option-value *unspecified*) + "The human-readable name used in the committer identity when creating +commit or tag objects, or when writing reflogs.") + (committer.email + (git-option-value *unspecified*) + "The email address used in the author identity when creating commit or tag +objects, or when writing reflogs.") + (commit.gpgSign + (git-option-value *unspecified*) + "A boolean to specify whether all commits should be GPG signed.") + (sendemail.smtpServer + (git-option-value *unspecified*) + "If set, specifies the outgoing SMTP server to +use (e.g. @code{smtp.example.com} or a raw IP address). If unspecified, and if +@var{sendemail.sendmailcmd} is also unspecified, the default is to search for +@command{sendmail} in $PATH if such a program is available, falling back to +@code{localhost} otherwise.") + (sendemail.smtpServerPort + (git-option-value *unspecified*) + "Specifies a port different from the default port (SMTP servers typically +listen to smtp port 25, but may also listen to submission port 587, or the +common SSL smtp port 465); symbolic port names (e.g. @code{submission} instead +of 587) are also accepted.") + (sendemail.smtpUser + (git-option-value *unspecified*) + "Username for SMTP-AUTH. If a username is not specified, then +authentication is not attempted.") + (sendemail.smtpPass + (git-option-value *unspecified*) + "Password for SMTP-AUTH. If not specified, then a password is obtained +using @command{git-credential}.") + (sendemail.smtpEncryption + (git-option-value *unspecified*) + "Specify the encryption to use, either @code{ssl} or @code{tls}. Any other +value reverts to plain SMTP.") + (sendemail.sendmailcmd + (git-option-value *unspecified*) + "Specify a command to run to send the email. The command should be +sendmail-like; specifically, it must support the @code{-i} option. The +command will be executed in the shell if necessary.") + (extra-options + (git-options '()) + "Extra configuration options for Git.")) + +(define (home-git-configuration-final-options config) + (let* ((fields + (filter + (lambda (field) + (eq? (configuration-field-type field) 'git-option-value)) + home-git-configuration-fields)) + (options + (filter + (match-lambda + ((section (key value)) (not (unspecified? value)))) + (map (lambda (field) + (let* ((name (configuration-field-name field)) + (section+key (map string->symbol + (string-split (symbol->string name) #\.))) + (value ((configuration-field-getter field) config))) + `(,(car section+key) (,(cadr section+key) ,value)))) + fields))) + (extra-options (home-git-configuration-extra-options config)) + (merge-options (lambda (options) ;merge options by section + (fold + (lambda (e prev) + (match e + ((section variables ..1) + (begin + (let ((v (assv-ref prev section))) + (assv-set! prev section + (if v (append v variables) + variables))))))) + '() options)))) + (merge-options (append options extra-options)))) + +(define (home-git-environment-variables config) + (let ((gitconfig (serialize-git-options + (home-git-configuration-final-options config)))) + `(("GIT_CONFIG_SYSTEM" . ,(plain-file "gitconfig" gitconfig))))) + +(define (home-git-profile config) + (let ((package (home-git-configuration-package config))) + (if (home-git-configuration-enable-send-email? config) + `(,package (,package "send-email")) + `(,package)))) + +(define home-git-service-type + (service-type (name 'home-git) + (extensions + (list (service-extension + home-environment-variables-service-type + home-git-environment-variables) + (service-extension + home-profile-service-type + home-git-profile))) + (default-value (home-git-configuration)) + (description + "Install and configure the Git distributed revision control +system."))) diff --git a/gnu/local.mk b/gnu/local.mk index 9bfeede60f..a5ea94b3a1 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -80,6 +80,7 @@ GNU_SYSTEM_MODULES = \ %D%/home.scm \ %D%/home/services.scm \ %D%/home/services/desktop.scm \ + %D%/home/services/git.scm \ %D%/home/services/symlink-manager.scm \ %D%/home/services/fontutils.scm \ %D%/home/services/shells.scm \ -- 2.34.0