Commit | Line | Data |
---|---|---|
62cab99c LC |
1 | ;;; Guix --- Nix package management from Guile. -*- coding: utf-8 -*- |
2 | ;;; Copyright (C) 2012 Ludovic Courtès <ludo@gnu.org> | |
3 | ;;; | |
4 | ;;; This file is part of Guix. | |
5 | ;;; | |
6 | ;;; 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. | |
10 | ;;; | |
11 | ;;; 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. | |
15 | ;;; | |
16 | ;;; You should have received a copy of the GNU General Public License | |
17 | ;;; along with Guix. If not, see <http://www.gnu.org/licenses/>. | |
18 | ||
19 | (define-module (guix download) | |
20 | #:use-module (ice-9 match) | |
21 | #:use-module (guix derivations) | |
22 | #:use-module (guix packages) | |
23 | #:use-module ((guix store) #:select (derivation-path?)) | |
24 | #:use-module (guix utils) | |
94d222ad | 25 | #:use-module (srfi srfi-26) |
ec4d308a LC |
26 | #:export (%mirrors |
27 | url-fetch)) | |
62cab99c LC |
28 | |
29 | ;;; Commentary: | |
30 | ;;; | |
31 | ;;; Produce fixed-output derivations with data fetched over HTTP or FTP. | |
32 | ;;; | |
33 | ;;; Code: | |
34 | ||
94d222ad LC |
35 | (define %mirrors |
36 | ;; Mirror lists used when `mirror://' URLs are passed. | |
37 | (let* ((gnu-mirrors | |
38 | '(;; This one redirects to a (supposedly) nearby and (supposedly) | |
39 | ;; up-to-date mirror. | |
40 | "http://ftpmirror.gnu.org/" | |
41 | ||
42 | "ftp://ftp.cs.tu-berlin.de/pub/gnu/" | |
43 | "ftp://ftp.chg.ru/pub/gnu/" | |
44 | "ftp://ftp.funet.fi/pub/mirrors/ftp.gnu.org/gnu/" | |
45 | ||
46 | ;; This one is the master repository, and thus it's always | |
47 | ;; up-to-date. | |
48 | "http://ftp.gnu.org/pub/gnu/"))) | |
49 | `((gnu ,@gnu-mirrors) | |
50 | (gcc | |
51 | "ftp://ftp.nluug.nl/mirror/languages/gcc/" | |
52 | "ftp://ftp.fu-berlin.de/unix/languages/gcc/" | |
53 | "ftp://ftp.irisa.fr/pub/mirrors/gcc.gnu.org/gcc/" | |
54 | "ftp://gcc.gnu.org/pub/gcc/" | |
55 | ,@(map (cut string-append <> "/gcc") gnu-mirrors)) | |
56 | (gnupg | |
57 | "ftp://gd.tuwien.ac.at/privacy/gnupg/" | |
58 | "ftp://gnupg.x-zone.org/pub/gnupg/" | |
59 | "ftp://ftp.gnupg.cz/pub/gcrypt/" | |
60 | "ftp://sunsite.dk/pub/security/gcrypt/" | |
61 | "http://gnupg.wildyou.net/" | |
62 | "http://ftp.gnupg.zone-h.org/" | |
63 | "ftp://ftp.jyu.fi/pub/crypt/gcrypt/" | |
64 | "ftp://trumpetti.atm.tut.fi/gcrypt/" | |
65 | "ftp://mirror.cict.fr/gnupg/" | |
66 | "ftp://ftp.strasbourg.linuxfr.org/pub/gnupg/") | |
67 | (savannah | |
68 | "http://download.savannah.gnu.org/" | |
69 | "ftp://ftp.twaren.net/Unix/NonGNU/" | |
70 | "ftp://mirror.csclub.uwaterloo.ca/nongnu/" | |
71 | "ftp://mirror.publicns.net/pub/nongnu/" | |
72 | "ftp://savannah.c3sl.ufpr.br/" | |
73 | "http://ftp.cc.uoc.gr/mirrors/nongnu.org/" | |
74 | "http://ftp.twaren.net/Unix/NonGNU/" | |
75 | "http://mirror.csclub.uwaterloo.ca/nongnu/" | |
76 | "http://nongnu.askapache.com/" | |
77 | "http://savannah.c3sl.ufpr.br/" | |
78 | "http://www.centervenus.com/mirrors/nongnu/") | |
79 | (sourceforge | |
80 | "http://prdownloads.sourceforge.net/" | |
81 | "http://heanet.dl.sourceforge.net/sourceforge/" | |
82 | "http://surfnet.dl.sourceforge.net/sourceforge/" | |
83 | "http://dfn.dl.sourceforge.net/sourceforge/" | |
84 | "http://mesh.dl.sourceforge.net/sourceforge/" | |
85 | "http://ovh.dl.sourceforge.net/sourceforge/" | |
86 | "http://osdn.dl.sourceforge.net/sourceforge/" | |
b40b259f LC |
87 | "http://kent.dl.sourceforge.net/sourceforge/") |
88 | (kernel.org | |
89 | "http://www.all.kernel.org/pub/" | |
90 | "http://ramses.wh2.tu-dresden.de/pub/mirrors/kernel.org/" | |
91 | "http://linux-kernel.uio.no/pub/" | |
92 | "http://kernel.osuosl.org/pub/" | |
93 | "ftp://ftp.funet.fi/pub/mirrors/ftp.kernel.org/pub/")))) | |
94d222ad LC |
94 | |
95 | ||
62cab99c LC |
96 | (define* (url-fetch store url hash-algo hash |
97 | #:optional name | |
94d222ad LC |
98 | #:key (system (%current-system)) guile |
99 | (mirrors %mirrors)) | |
62cab99c LC |
100 | "Return the path of a fixed-output derivation in STORE that fetches |
101 | URL (a string, or a list of strings denoting alternate URLs), which is | |
102 | expected to have hash HASH of type HASH-ALGO (a symbol). By default, | |
103 | the file name is the base name of URL; optionally, NAME can specify a | |
94d222ad LC |
104 | different file name. |
105 | ||
106 | When one of the URL starts with mirror://, then its host part is | |
107 | interpreted as the name of a mirror scheme, taken from MIRRORS; MIRRORS | |
108 | must be a list of symbol/URL-list pairs." | |
62cab99c LC |
109 | (define builder |
110 | `(begin | |
111 | (use-modules (guix build download)) | |
94d222ad LC |
112 | (url-fetch ',url %output |
113 | #:mirrors ',mirrors))) | |
62cab99c LC |
114 | |
115 | (define guile-for-build | |
116 | (match guile | |
117 | ((? package?) | |
118 | (package-derivation store guile system)) | |
119 | ((and (? string?) (? derivation-path?)) | |
120 | guile) | |
121 | (#f ; the default | |
122 | (let* ((distro (resolve-interface '(distro packages base))) | |
123 | (guile (module-ref distro 'guile-final))) | |
124 | (package-derivation store guile system))))) | |
125 | ||
126 | (define file-name | |
127 | (match url | |
128 | ((head _ ...) | |
129 | (basename head)) | |
130 | (_ | |
131 | (basename url)))) | |
132 | ||
133 | (build-expression->derivation store (or name file-name) system | |
134 | builder '() | |
135 | #:hash-algo hash-algo | |
136 | #:hash hash | |
137 | #:modules '((guix build download) | |
138 | (guix build utils) | |
139 | (guix ftp-client)) | |
140 | #:guile-for-build guile-for-build)) | |
141 | ||
142 | ;;; download.scm ends here |