1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2014 Ludovic Courtès <ludo@gnu.org>
4 ;;; This file is part of GNU Guix.
6 ;;; GNU Guix is free software; you can redistribute it and/or modify it
7 ;;; under the terms of the GNU General Public License as published by
8 ;;; the Free Software Foundation; either version 3 of the License, or (at
9 ;;; your option) any later version.
11 ;;; GNU Guix is distributed in the hope that it will be useful, but
12 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;;; GNU General Public License for more details.
16 ;;; You should have received a copy of the GNU General Public License
17 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
19 (define-module (guix git-download)
20 #:use-module (guix records)
21 #:use-module (guix derivations)
22 #:use-module (guix packages)
23 #:use-module (ice-9 match)
24 #:export (git-reference
33 ;;; An <origin> method that fetches a specific commit from a Git repository.
34 ;;; The repository URL and commit hash are specified with a <git-reference>
39 (define-record-type* <git-reference>
40 git-reference make-git-reference
42 (url git-reference-url)
43 (commit git-reference-commit))
45 (define* (git-fetch store ref hash-algo hash
47 #:key (system (%current-system)) guile git)
48 "Return a fixed-output derivation in STORE that fetches REF, a
49 <git-reference> object. The output is expected to have recursive hash HASH of
50 type HASH-ALGO (a symbol). Use NAME as the file name, or a generic name if
52 (define guile-for-build
55 (package-derivation store guile system))
57 (let* ((distro (resolve-interface '(gnu packages base)))
58 (guile (module-ref distro 'guile-final)))
59 (package-derivation store guile system)))))
64 (package-derivation store git system))
66 (let* ((distro (resolve-interface '(gnu packages version-control)))
67 (git (module-ref distro 'git)))
68 (package-derivation store git system)))))
70 (let* ((command (string-append (derivation->output-path git-for-build)
73 (use-modules (guix build git))
74 (git-fetch ',(git-reference-url ref)
75 ',(git-reference-commit ref)
77 #:git-command ',command))))
78 (build-expression->derivation store (or name "git-checkout") builder
81 #:inputs `(("git" ,git-for-build))
85 #:modules '((guix build git)
87 #:guile-for-build guile-for-build
90 ;;; git-download.scm ends here