unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
blob 2c3f87fbabcb3afaefbbab885934f6405ad4d620 3301 bytes (raw)
name: gnu/home/services/git.scm 	 # note: path name is non-authoritative(*)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
 
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2022 宋文武 <iyzsong@member.fsf.org>
;;;
;;; 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 <http://www.gnu.org/licenses/>.

(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.")))

debug log:

solving 2c3f87fbab ...
found 2c3f87fbab in https://yhetil.org/guix-patches/TYCP286MB189799FE00EC37FC1D454CA2A3089@TYCP286MB1897.JPNP286.PROD.OUTLOOK.COM/

applying [1/1] https://yhetil.org/guix-patches/TYCP286MB189799FE00EC37FC1D454CA2A3089@TYCP286MB1897.JPNP286.PROD.OUTLOOK.COM/
diff --git a/gnu/home/services/git.scm b/gnu/home/services/git.scm
new file mode 100644
index 0000000000..2c3f87fbab

Checking patch gnu/home/services/git.scm...
Applied patch gnu/home/services/git.scm cleanly.

index at:
100644 2c3f87fbabcb3afaefbbab885934f6405ad4d620	gnu/home/services/git.scm

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).