From patchwork Mon Mar 7 14:51:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?5a6L5paH5q2m?= X-Patchwork-Id: 37641 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 26E8427BBEA; Mon, 7 Mar 2022 15:12:13 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 812E927BBE9 for ; Mon, 7 Mar 2022 15:12:12 +0000 (GMT) Received: from localhost ([::1]:41614 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRF1v-0001Uf-MA for patchwork@mira.cbaines.net; Mon, 07 Mar 2022 10:12:11 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59598) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRF1n-0001Rr-80 for guix-patches@gnu.org; Mon, 07 Mar 2022 10:12:03 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:60492) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nRF1m-0007mw-Vh for guix-patches@gnu.org; Mon, 07 Mar 2022 10:12:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nRF1m-0005QW-N5 for guix-patches@gnu.org; Mon, 07 Mar 2022 10:12:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#54293] [WIP] home: Add home-git-service-type Resent-From: =?utf-8?b?5a6L5paH5q2m?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 07 Mar 2022 15:12:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 54293 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: To: 54293@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.164666586220788 (code B ref -1); Mon, 07 Mar 2022 15:12:02 +0000 Received: (at submit) by debbugs.gnu.org; 7 Mar 2022 15:11:02 +0000 Received: from localhost ([127.0.0.1]:54389 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nRF0l-0005Ou-Cm for submit@debbugs.gnu.org; Mon, 07 Mar 2022 10:11:02 -0500 Received: from lists.gnu.org ([209.51.188.17]:58068) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nRF0i-0005Ok-Um for submit@debbugs.gnu.org; Mon, 07 Mar 2022 10:10:57 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59244) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRF0i-0008Kv-Qt for guix-patches@gnu.org; Mon, 07 Mar 2022 10:10:56 -0500 Received: from mail-tycjpn01olkn2036.outbound.protection.outlook.com ([40.92.99.36]:62824 helo=JPN01-TYC-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRF0g-0007Zo-DU for guix-patches@gnu.org; Mon, 07 Mar 2022 10:10:56 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YdAgraY2EmVPDU2ppwc6OBDavzskO9bK3hntlRp8z8ocHA95uwjzx+vmPNYNM6moeMfDY2NnvMZ88jTBIuUBQ6ZKwccbs6y9viFISlpwsHvJSCZ1re98G7x6ZUpbeCOMcWVPQVFlsn7kfNy8WOhx0hsUcoEUU+w2V6K7BHA3qUSzX0PUtalz5D3v/yl+G4laMTSBsKj0ugTSDhUl6dIpSOpxNMeFnRhh7hWIDV43VsnBUu2vH3gobRCYdtjsA/6teUzLm3VdjFwPZoh4jBEFw+yAHoOlv2VnoHUXEI6xioOyzbCVDYdrgxRMUp4CLKzPkKbK7h5xTlpmzhFqCv73cw== 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=S8/JDdZzanCsbGgr1wOQLKsGV/9whUAc43O3EZdTKbw=; b=UhzUApzM5Xq4A+l4DXBVW+env0M08NAVbELgssaUm277Lq4Z1CvdOj9AcVLKBSn6W7pR7d//8y/9mU2kNNkS0eiZ94A8BJ36glfEq46Mqb/C6J+RuMhmElOkTXsNocyW7lT4HUdNZ3FAWobVAl/dE1G8GXgdjvo1IpdGaqZ9pnESGA0vqBdHtsFyqssWNE0Avv+Bojugrv10kZcVNdmd62PIOkNvup0KgEz+xqBCmkKE7LveQpzsX3ra3hMdmIdzKqRmMMoi1D0LrNy3it9r6aig+B+PZe6NbZcv/3JWjRBzZqigfvXACZv4ANWmFK8L3dW+4FUvxu7aYodLAp9LeQ== 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=S8/JDdZzanCsbGgr1wOQLKsGV/9whUAc43O3EZdTKbw=; b=Wp6b+pq+/9J7nMW+APVTxddpZ8tnKxWbQjewwlZ748sI+Yx+v3bAH0k+TMYKpi6PeuWw4lNDDlWurp4CqnyWHTga9Fty5qPHF3t0Cd3rXgnYQpa3g9bf6wznFdkUR4BvmNDplWFDI0hHvNtYj737dHPAkr7yjuj/HSHhAEJbva+0XnLNnZ04VQVGXohJUBkEZQ7mI5shA7vVP0hoFV7uCP3vwEMRJ8/OlNbVMQjmLJJxEnOg0ZQZhkZSI+KKyhbZkLmYiwStqBMVDy3Y2E8Xh2dxC+jVugBUwoCjFjxUbWCWcpI5doX1UvvnJrDizdK26/xR27+MmnaAt08BPzGRDQ== Received: from TYCP286MB1897.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:11e::13) by TYCP286MB1282.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:b9::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.14; Mon, 7 Mar 2022 14:51:09 +0000 Received: from TYCP286MB1897.JPNP286.PROD.OUTLOOK.COM ([fe80::51f5:8561:6bc0:1f64]) by TYCP286MB1897.JPNP286.PROD.OUTLOOK.COM ([fe80::51f5:8561:6bc0:1f64%5]) with mapi id 15.20.5038.027; Mon, 7 Mar 2022 14:51:09 +0000 From: =?utf-8?b?5a6L5paH5q2m?= Date: Mon, 07 Mar 2022 22:51:03 +0800 Message-ID: X-TMN: [NHz8vxalfnfqOImvSw2K40Zu/6KypvYvwli6PV/buysPmYB3PkHbC/DiyrSup4KR] X-ClientProxiedBy: HK2PR02CA0168.apcprd02.prod.outlook.com (2603:1096:201:1f::28) To TYCP286MB1897.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:11e::13) X-Microsoft-Original-Message-ID: <87y21lyfxk.fsf@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0abdfed5-7052-4749-3ac3-08da0049e8aa X-MS-TrafficTypeDiagnostic: TYCP286MB1282:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: flYMqEK2C/3v7XUPAxj2e3zBJtDSqEIK4hqHu2BwY42Gjmtx0cP6MP5OZOUIiI28b4kWBP34/1Ro7UyUn3k7wY/RdLq+f/5eXXuC9U37Laq5EfLxOlfAiNdb2KSGLPs/b4d7uTXmqORsSgW0EV/eSwQ3o/Wnpd7sg3mDjFTm+tuIzNf8jlRrZvo3vUIy0MVpoxekk8tFw9tYiqEgrg7/upr10RgC2TkJX9aP8BI1xUgQfY8AXZI8juc2yXDaeiRtte2VOQjLbn43L+eaxGe8q61xnRCjoJNCUgbQ/dtvG1mfuLX0kuLztnAEADb/Gm7d9Ndb2fq1ScPbCLDbnBBAM3cPXrzDTDdIcr2SNCJz0f2WNfpmZHKawwl46rCgVPeZIgjRH6eO82TirWB77Rms+RSi70cVGHABsNC8tt0NWVt8yIPVOa4g2DvA6PcwXRyDcFm36d1D++VEkIMfgZRRa9sj5W2nY8xXfoBTGDKFQWhbB+t05Ph5kvA/Rtk8HAgW8pMjdLBlk9pz7KnY5okhPulo6HZKBA/u9Nf8uzaLM4jOYK3vrETHm/G4MAowuTuvF+kbjs6Ahe9r+kPVGslZFg== X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Bu9Fz5WUoXjiUt5OI4vkgBadBOL4XEk6jKYMEkcw1Yp17ym9zclKtC7roUUD+Kx0SQi3ERbG9pOYo2ayUucgLn85/S4kx+Ol3gfIdgO1L1wbavOQmkuTB5Bg2dTlwOUvcD3bhc5q3eGzqt8Bu0NoUW37Evvl7+1cxYOEBsg9qHv0XB6yM/XblrGJLnKOf8mAhhmh5eFnzWiHVGXrH5DHxIYfR1ACgNlWqw6wwdlrLf4Mhtkbp0laKDUHsiUNgsXnyjCY0xUd96mgYPcoLh2ovHyA3g6NrobLSCzFpWF6QmeZVgNEYoSxwK8Q/ZTyb2PxAP5dfAvEv82+He7hV42Opm95+82Jwl8mjBF6n0xXB7wawMy1+mddRzhGIA8duQeg2LItrg28ymoRbxFzz6svQIlHqt3cq3MgYjulEydxl3dNwxI1wgFkZRSlMeMfOe0QpoxwCcjD60dJIBFS1/dS8cPdkjcZW62512TDSHGjGRKH/4iRCfwGlE9UcCa3TTWvkt1Ss35x1ujr3XSqQ4Bqsa5zL0gBYkdnTAbZp5xZ77lHzcZq85QHzPtIzBtRjnZUZncy1+LvBz2TA9BJqVNdhhYcMF6JANe37hyu7+LDmNA6w80QjYnYjcuGCfyFP5mTymLsGZOcSnOsbKzVowDTSgH4nBa/nJ+5qHMopK6r6mTlaixv5ZkDqo328cZMxsux91p07D/IfRXjUhK9b4jlXf6hcB8FvH8QEqt02TbmO8xtlqheXRgtJuMF505Pb6WdmD0DItjbYP2IZI0tBz+ZwqLUIhK7Sq1/TW1pueHZo68JXV0bYQ/hrh5PG4+nX1Mu0kI8KvafcaPulz6I1obaIva53YUJIZ5JpQa1WOMZgECn6hHdXHbpr0ugp9lFXheL4LvS8N52HJ1/76FaIIA9e8R6IGvGysfN3NXGjdQBpx8Yk4CVwGki5XiCcGioW3BNfT6usLFi8qMi1vGM0Uhxa2LBMeC3NGpwx9ow8bBNW8JhN13g3Re7Jln4zEY8iFYAgiADAykCcOmAASKMTR8DFw== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0abdfed5-7052-4749-3ac3-08da0049e8aa X-MS-Exchange-CrossTenant-AuthSource: TYCP286MB1897.JPNP286.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Mar 2022 14:51:08.9786 (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: TYCP286MB1282 Received-SPF: pass client-ip=40.92.99.36; envelope-from=iyzsong@outlook.com; helo=JPN01-TYC-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action 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+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches Hello, with: --8<---------------cut here---------------start------------->8--- (service home-git-service-type (home-git-configuration (options '((user (name "foo") (email "foo@bar.com")))))) --8<---------------cut here---------------end--------------->8--- We'll have git in the home profile, and GIT_CONFIG_SYSTEM pointing to a file contains: --8<---------------cut here---------------start------------->8--- [user] name = "foo" email = "foo@bar.com" --8<---------------cut here---------------end--------------->8--- Which set the system-level options for git. I made 'options' an sexp value since there are so many git options (see 'man git-config'). When `options' is invalid, `guix home' will reports: 'guix home: error: Invalid value for field options: ......', is this acceptable or how to make a better validation error report? I can also symlink the generated gitconfig into ~/.gitconfig, but with 'GIT_CONFIG_SYSTEM' it can be used together with hand maintained ~/.gitconfig. Documentation is lacking, I'm still bad at them... Any interest or review feedback? Thanks! I'd like to write more home services for msmtp, emacs, foot, etc. to configure my whole user session :) From d161786c675a12f9cb2bce2bdb965d65eb5281ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=8B=E6=96=87=E6=AD=A6?= Date: Mon, 7 Mar 2022 22:14:09 +0800 Subject: [PATCH] home: Add home-git-service-type. * gnu/home/services/git.scm: New file. * gnu/local.mk (GNU_SYSTEM_MODULES): Add it. --- gnu/home/services/git.scm | 95 +++++++++++++++++++++++++++++++++++++++ gnu/local.mk | 1 + 2 files changed, 96 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..2c3f87fbab --- /dev/null +++ b/gnu/home/services/git.scm @@ -0,0 +1,95 @@ +;;; 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-options? options) + "Return #t if OPTIONS is a well-formed sexp for git options." + (define git-variable? + (match-lambda + ((key value) (and (symbol? key) (string? 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) + (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 = ~s~%" key value))) + variables)))))) + (string-concatenate (map serialize-section options))) + +(define-configuration home-git-configuration + (package + (package git) + "The Git package to use.") + (options + (git-options '()) + "System configuration options for Git.")) + + +(define (home-git-environment-variables config) + (let ((gitconfig (serialize-git-options + (home-git-configuration-options config)))) + `(("GIT_CONFIG_SYSTEM" . ,(plain-file "gitconfig" gitconfig))))) + +(define (home-git-profile config) + (list (home-git-configuration-package config))) + +(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