profiles: Use 'with-imported-modules'.
[jackhill/guix/guix.git] / guix / svn-download.scm
CommitLineData
b3acf365 1;;; GNU Guix --- Functional package management for GNU
e87f0591 2;;; Copyright © 2014, 2015 Ludovic Courtès <ludo@gnu.org>
b3acf365
SHT
3;;; Copyright © 2014 Sree Harsha Totakura <sreeharsha@totakura.in>
4;;;
5;;; This file is part of GNU Guix.
6;;;
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.
11;;;
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.
16;;;
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/>.
19
20(define-module (guix svn-download)
21 #:use-module (guix records)
bc672694 22 #:use-module (guix gexp)
e87f0591 23 #:use-module (guix store)
bc672694 24 #:use-module (guix monads)
b3acf365
SHT
25 #:use-module (guix packages)
26 #:use-module (ice-9 match)
27 #:export (svn-reference
28 svn-reference?
29 svn-reference-url
30 svn-reference-revision
31 svn-fetch))
32
33;;; Commentary:
34;;;
35;;; An <origin> method that fetches a specific revision from a Subversion
36;;; repository. The repository URL and REVISION are specified with a
37;;; <svn-reference> object. REVISION should be specified as a number.
38;;;
39;;; Code:
40
41(define-record-type* <svn-reference>
42 svn-reference make-svn-reference
43 svn-reference?
140dd8f8
RW
44 (url svn-reference-url) ; string
45 (revision svn-reference-revision) ; number
46 (user-name svn-reference-user-name (default #f))
47 (password svn-reference-password (default #f)))
b3acf365 48
bc672694
LC
49(define (subversion-package)
50 "Return the default Subversion package."
51 (let ((distro (resolve-interface '(gnu packages version-control))))
52 (module-ref distro 'subversion)))
53
f220a838 54(define* (svn-fetch ref hash-algo hash
b3acf365 55 #:optional name
f220a838 56 #:key (system (%current-system)) (guile (default-guile))
bc672694 57 (svn (subversion-package)))
f220a838
LC
58 "Return a fixed-output derivation that fetches REF, a <svn-reference>
59object. The output is expected to have recursive hash HASH of type
60HASH-ALGO (a symbol). Use NAME as the file name, or a generic name if #f."
bc672694
LC
61 (define build
62 #~(begin
63 (use-modules (guix build svn))
64 (svn-fetch '#$(svn-reference-url ref)
65 '#$(svn-reference-revision ref)
66 #$output
140dd8f8
RW
67 #:svn-command (string-append #+svn "/bin/svn")
68 #:user-name #$(svn-reference-user-name ref)
69 #:password #$(svn-reference-password ref))))
b3acf365 70
f220a838 71 (mlet %store-monad ((guile (package->derivation guile system)))
bc672694
LC
72 (gexp->derivation (or name "svn-checkout") build
73 #:system system
bc672694
LC
74 #:hash-algo hash-algo
75 #:hash hash
76 #:recursive? #t
77 #:modules '((guix build svn)
78 (guix build utils))
f220a838
LC
79 #:guile-for-build guile
80 #:local-build? #t)))
b3acf365
SHT
81
82;;; svn-download.scm ends here