1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2014, 2015, 2016, 2017 Ludovic Courtès <ludo@gnu.org>
3 ;;; Copyright © 2016 Ricardo Wurmus <rekado@elephly.net>
5 ;;; This file is part of GNU Guix.
7 ;;; GNU Guix is free software; you can redistribute it and/or modify it
8 ;;; under the terms of the GNU General Public License as published by
9 ;;; the Free Software Foundation; either version 3 of the License, or (at
10 ;;; your option) any later version.
12 ;;; GNU Guix is distributed in the hope that it will be useful, but
13 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;;; GNU General Public License for more details.
17 ;;; You should have received a copy of the GNU General Public License
18 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
20 (define-module (guix hg-download)
21 #:use-module (guix gexp)
22 #:use-module (guix store)
23 #:use-module (guix monads)
24 #:use-module (guix records)
25 #:use-module (guix modules)
26 #:use-module (guix packages)
27 #:autoload (guix build-system gnu) (standard-packages)
28 #:use-module (ice-9 match)
29 #:export (hg-reference
32 hg-reference-changeset
33 hg-reference-recursive?
39 ;;; An <origin> method that fetches a specific changeset from a Mercurial
40 ;;; repository. The repository URL and changeset ID are specified with a
41 ;;; <hg-reference> object.
45 (define-record-type* <hg-reference>
46 hg-reference make-hg-reference
48 (url hg-reference-url)
49 (changeset hg-reference-changeset))
52 "Return the default Mercurial package."
53 (let ((distro (resolve-interface '(gnu packages version-control))))
54 (module-ref distro 'mercurial)))
56 (define* (hg-fetch ref hash-algo hash
58 #:key (system (%current-system)) (guile (default-guile))
60 "Return a fixed-output derivation that fetches REF, a <hg-reference>
61 object. The output is expected to have recursive hash HASH of type
62 HASH-ALGO (a symbol). Use NAME as the file name, or a generic name if #f."
64 (module-ref (resolve-interface '(gnu packages compression)) 'zlib))
67 (scheme-file "config.scm"
69 (define-module (guix config)
73 #+(file-append zlib "/lib/libz")))))
76 (cons `((guix config) => ,config.scm)
77 (delete '(guix config)
78 (source-module-closure '((guix build hg)
79 (guix build download-nar))))))
82 (with-imported-modules modules
84 (use-modules (guix build hg)
85 (guix build download-nar))
87 (or (hg-fetch '#$(hg-reference-url ref)
88 '#$(hg-reference-changeset ref)
90 #:hg-command (string-append #+hg "/bin/hg"))
91 (download-nar #$output)))))
93 (mlet %store-monad ((guile (package->derivation guile system)))
94 (gexp->derivation (or name "hg-checkout") build
96 #:local-build? #t ;don't offload repo cloning
100 #:guile-for-build guile)))
102 ;;; hg-download.scm ends here