summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNguyễn Gia Phong <mcsinyx@disroot.org>2025-11-27 17:46:50 +0900
committerLiliana Marie Prikler <liliana.prikler@gmail.com>2026-04-15 23:10:25 +0200
commit05e669ac50cd15db30c2bfc0681a4c2a24cf080d (patch)
tree724f182b0d66d5bda6b553a516f9f6bcc7d3bbe6
parent08341ec277cdeb84e662e3c11ab2b4ada06fd48b (diff)
guix: Implement fossil-download.
* guix/fossil-download.scm: New file. * guix/build/fossil.scm: New file. * Makefile.am (MODULES): Add them. * etc/teams.scm (core)[#:scope]: Add "guix/fossil-download.scm". (vcs)[#:scope]: Add "guix/build/fossil.scm". * CODEOWNERS: Regenerate file. * doc/guix.texi (origin Reference): Document fossil-fetch and fossil-reference. * NEWS: Add entry about fossil-fetch. Change-Id: Ia252bcbbb417159a842d5092a937e2aad55a1656 Signed-off-by: Liliana Marie Prikler <liliana.prikler@gmail.com>
-rw-r--r--CODEOWNERS2
-rw-r--r--Makefile.am2
-rw-r--r--NEWS3
-rw-r--r--doc/guix.texi46
-rwxr-xr-xetc/teams.scm2
-rw-r--r--guix/build/fossil.scm59
-rw-r--r--guix/fossil-download.scm125
7 files changed, 239 insertions, 0 deletions
diff --git a/CODEOWNERS b/CODEOWNERS
index 2daec3630cc..1b7dc17d1f5 100644
--- a/CODEOWNERS
+++ b/CODEOWNERS
@@ -68,6 +68,7 @@ guix/discovery\.scm @guix/core
68guix/docker\.scm @guix/core 68guix/docker\.scm @guix/core
69guix/download\.scm @guix/core 69guix/download\.scm @guix/core
70guix/elf\.scm @guix/core 70guix/elf\.scm @guix/core
71guix/fossil-download\.scm @guix/core
71guix/ftp-client\.scm @guix/core 72guix/ftp-client\.scm @guix/core
72guix/gexp\.scm @guix/core 73guix/gexp\.scm @guix/core
73guix/git-authenticate\.scm @guix/core 74guix/git-authenticate\.scm @guix/core
@@ -484,6 +485,7 @@ gnu/services/version-control\.scm @guix/vcs
484gnu/tests/version-control\.scm @guix/vcs 485gnu/tests/version-control\.scm @guix/vcs
485guix/build/bzr\.scm @guix/vcs 486guix/build/bzr\.scm @guix/vcs
486guix/build/cvs\.scm @guix/vcs 487guix/build/cvs\.scm @guix/vcs
488guix/build/fossil\.scm @guix/vcs
487guix/build/git\.scm @guix/vcs 489guix/build/git\.scm @guix/vcs
488guix/build/hg\.scm @guix/vcs 490guix/build/hg\.scm @guix/vcs
489guix/build/svn\.scm @guix/vcs 491guix/build/svn\.scm @guix/vcs
diff --git a/Makefile.am b/Makefile.am
index 976c5cad742..7fd6cf892f3 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -104,6 +104,7 @@ MODULES = \
104 guix/discovery.scm \ 104 guix/discovery.scm \
105 guix/android-repo-download.scm \ 105 guix/android-repo-download.scm \
106 guix/bzr-download.scm \ 106 guix/bzr-download.scm \
107 guix/fossil-download.scm \
107 guix/git-download.scm \ 108 guix/git-download.scm \
108 guix/hg-download.scm \ 109 guix/hg-download.scm \
109 guix/hash.scm \ 110 guix/hash.scm \
@@ -236,6 +237,7 @@ MODULES = \
236 guix/build/asdf-build-system.scm \ 237 guix/build/asdf-build-system.scm \
237 guix/build/bzr.scm \ 238 guix/build/bzr.scm \
238 guix/build/copy-build-system.scm \ 239 guix/build/copy-build-system.scm \
240 guix/build/fossil.scm \
239 guix/build/git.scm \ 241 guix/build/git.scm \
240 guix/build/hg.scm \ 242 guix/build/hg.scm \
241 guix/build/glib-or-gtk-build-system.scm \ 243 guix/build/glib-or-gtk-build-system.scm \
diff --git a/NEWS b/NEWS
index 6fd51b38fa4..4d95880c575 100644
--- a/NEWS
+++ b/NEWS
@@ -20,6 +20,9 @@ Please send Guix bug reports to bug-guix@gnu.org.
20*** New service for Fossil SCM 20*** New service for Fossil SCM
21*** TeX Live updated to 2026.1 21*** TeX Live updated to 2026.1
22 22
23** Programming interfaces
24*** New (guix fossil-download) module, for fetching Fossil repositories
25
23* Changes in 1.5.0 (since 1.4.0) 26* Changes in 1.5.0 (since 1.4.0)
24** Package management 27** Package management
25*** New ‘rpm’ format for the ‘guix pack’ command 28*** New ‘rpm’ format for the ‘guix pack’ command
diff --git a/doc/guix.texi b/doc/guix.texi
index 198ecb3413b..aaee903d95a 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -8737,6 +8737,52 @@ The example below denotes a version of gnu-standards to fetch:
8737 8737
8738@end deftp 8738@end deftp
8739 8739
8740For Fossil repositories, the module @code{(guix fossil-download)} defines
8741the @code{fossil-fetch} origin method and @code{fossil-reference} data type
8742for support of the Fossil @abbr{SCM, software configuration management} system.
8743
8744@deffn {Procedure} fossil-fetch ref hash-algo hash [name]
8745Return a fixed-output derivation that fetches @var{ref}, a
8746@code{<fossil-reference>} object. The output is expected to have recursive
8747hash @var{hash} of type @var{hash-algo} (a symbol). Use @var{name} as
8748the file name, or a generic name if @code{#f}.
8749@end deffn
8750
8751@deftp {Data Type} fossil-reference
8752This data type represents a Fossil reference
8753for @code{fossil-fetch} to retrieve.
8754
8755@table @asis
8756@item @code{uri} (type: string)
8757The URI of a Fossil repository to clone, in one of the following forms,
8758in which @code{[...]} denotes optional elements:
8759
8760@table @code
8761@item http[s]://[userid[:password]@@]host[:port][/path]
8762A HTTP/HTTPS URL.
8763@item [file://]path/to/repo.fossil
8764A file URI, where the path must have an extra leading @code{/}
8765to use an absolute path (without the URI scheme, the repository
8766is opened directly without cloning).
8767@end table
8768
8769@item @code{check-in} (type: string)
8770A @url{https://fossil-scm.org/home/doc/trunk/www/checkin_names.wiki,
8771name of the check-in} to fetch, e.g.@: its canonical hexadecimal identifier,
8772associated tag and/or timestamp.
8773@end table
8774
8775The example below denotes the @code{version-3.51.1} tag
8776of the SQLite repository:
8777
8778@lisp
8779(fossil-reference
8780 (uri "https://sqlite.org/src")
8781 (check-in "version-3.51.1"))
8782@end lisp
8783
8784@end deftp
8785
8740@node Defining Package Variants 8786@node Defining Package Variants
8741@section Defining Package Variants 8787@section Defining Package Variants
8742 8788
diff --git a/etc/teams.scm b/etc/teams.scm
index c26a0c11f83..1e179f445df 100755
--- a/etc/teams.scm
+++ b/etc/teams.scm
@@ -565,6 +565,7 @@ challenges"))
565 "guix/docker.scm" 565 "guix/docker.scm"
566 "guix/download.scm" 566 "guix/download.scm"
567 "guix/elf.scm" 567 "guix/elf.scm"
568 "guix/fossil-download.scm"
568 "guix/ftp-client.scm" 569 "guix/ftp-client.scm"
569 "guix/gexp.scm" 570 "guix/gexp.scm"
570 "guix/git-authenticate.scm" 571 "guix/git-authenticate.scm"
@@ -1214,6 +1215,7 @@ the \"texlive\" importer."
1214 "gnu/tests/version-control.scm" 1215 "gnu/tests/version-control.scm"
1215 "guix/build/bzr.scm" 1216 "guix/build/bzr.scm"
1216 "guix/build/cvs.scm" 1217 "guix/build/cvs.scm"
1218 "guix/build/fossil.scm"
1217 "guix/build/git.scm" 1219 "guix/build/git.scm"
1218 "guix/build/hg.scm" 1220 "guix/build/hg.scm"
1219 "guix/build/svn.scm"))) 1221 "guix/build/svn.scm")))
diff --git a/guix/build/fossil.scm b/guix/build/fossil.scm
new file mode 100644
index 00000000000..a8c03e3eb80
--- /dev/null
+++ b/guix/build/fossil.scm
@@ -0,0 +1,59 @@
1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2025 Nguyễn Gia Phong <cnx@loang.net>
3;;;
4;;; This file is part of GNU Guix.
5;;;
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.
10;;;
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.
15;;;
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/>.
18;;;
19;;; Commentary:
20;;;
21;;; This is the build-side support code of (guix fossil-download).
22;;; It allows a Fossil repository to be opened at a specific revision.
23;;;
24;;; Code:
25
26(define-module (guix build fossil)
27 #:use-module (guix build utils)
28 #:use-module (ice-9 match)
29 #:use-module (srfi srfi-26)
30 #:use-module (srfi srfi-34)
31 #:use-module (srfi srfi-35)
32 #:use-module (web uri)
33 #:export (fossil-fetch))
34
35(define* (fossil-fetch uri check-in file #:key (fossil-command "fossil"))
36 "Fetch CHECK-IN from URI into DIRECTORY. CHECK-IN must be a valid
37Fossil check-in name. Return #t on success, else raise an exception."
38 (setenv "FOSSIL_HOME" "/tmp")
39 (invoke fossil-command
40 "tarball" check-in file "-R"
41 (case (uri-scheme (string->uri-reference uri))
42 ((file https) ;clone the repository first
43 (match-let ((repository (simple-format #f "/tmp/~a.fossil"
44 (basename file ".tar.gz")))
45 ((input . output) (pipe)))
46 ;; Trust the TLS certificate of the server,
47 ;; since we'll later verify the tarball's checksum.
48 (display "y" output)
49 (close-port output)
50 (with-input-from-port input
51 (cut invoke fossil-command "clone"
52 "--no-open" "--once" uri repository))
53 (close-port input)
54 repository))
55 ((ssh) ;TODO: authentication for SSH
56 (let ((message (string-append "fetching a Fossil repository through SSH"
57 " is not supported: " uri)))
58 (raise (condition (&message (message message))))))
59 ((#f) uri)))) ;local file
diff --git a/guix/fossil-download.scm b/guix/fossil-download.scm
new file mode 100644
index 00000000000..d371ee2d0db
--- /dev/null
+++ b/guix/fossil-download.scm
@@ -0,0 +1,125 @@
1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2025 Nguyễn Gia Phong <cnx@loang.net>
3;;;
4;;; This file is part of GNU Guix.
5;;;
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.
10;;;
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.
15;;;
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/>.
18;;;
19;;; Commentary:
20;;;
21;;; An <origin> method that open Fossil checkout at a specific version.
22;;; The repository URI and version are specified
23;;; with a <fossil-reference> object.
24;;;
25;;; Code:
26
27(define-module (guix fossil-download)
28 #:use-module (guix build-system)
29 #:use-module (guix gexp)
30 #:use-module (guix modules)
31 #:use-module (guix monads)
32 #:use-module (guix packages)
33 #:use-module (guix records)
34 #:use-module (guix store)
35 #:use-module (ice-9 match)
36 #:use-module (srfi srfi-34)
37 #:use-module (srfi srfi-35)
38 #:use-module (web uri)
39 #:export (fossil-reference
40 fossil-reference?
41 fossil-reference-uri
42 fossil-reference-check-in
43
44 fossil-fetch
45 fossil-version
46 fossil-file-name))
47
48(define-record-type* <fossil-reference>
49 fossil-reference make-fossil-reference fossil-reference?
50 (uri fossil-reference-uri)
51 (check-in fossil-reference-check-in))
52
53(define (fossil-version version revision check-in)
54 "Return the version string for packages using fossil-download."
55 ;; fossil-version is almost exclusively executed while modules
56 ;; are being loaded, leading to any errors hiding their backtrace.
57 ;; Avoid the mysterious error "Value out of range 0 to N: 10"
58 ;; when the check-in ID is too short, which can happen, for example,
59 ;; when the user swapped the revision and check-in arguments by mistake.
60 (when (< (string-length check-in) 10)
61 (raise
62 (condition
63 (&message (message "fossil-version: check-in ID unexpectedly short")))))
64 (string-append version "-" revision "." (string-take check-in 10)))
65
66(define (fossil-file-name name version)
67 "Return the file-name for packages using fossil-download."
68 (string-append name "-" version ".tar.gz"))
69
70(define* (fossil-fetch ref hash-algo hash
71 #:optional name
72 #:key (system (%current-system))
73 (guile (default-guile))
74 (fossil (@* (gnu packages version-control)
75 fossil)))
76 "Return a fixed-output derivation that fetches REF, a <fossil-reference>
77object. The output is expected to have recursive hash HASH of type
78HASH-ALGO (a symbol). Use NAME as the file name, or a generic name if #f."
79 (let* ((modules (source-module-closure '((guix build fossil)
80 (guix build download)
81 (guix build download-nar))))
82 (uri (fossil-reference-uri ref))
83 (scheme-of-uri (uri-scheme (string->uri-reference uri)))
84 (check-in (fossil-reference-check-in ref))
85 (tarball-name (or name (fossil-file-name (basename uri) check-in)))
86 (tarball-url (and (eq? 'https scheme-of-uri)
87 (simple-format #f "~a/tarball/~a/~a"
88 uri check-in tarball-name)))
89 (guile-json (@* (gnu packages guile) guile-json-4))
90 (gnutls (@* (gnu packages tls) guile-gnutls))
91 (guile-lzlib (@* (gnu packages guile) guile-lzlib))
92 (build
93 (with-imported-modules modules
94 (with-extensions (list guile-json gnutls ;for (guix swh)
95 guile-lzlib)
96 #~(begin
97 (use-modules (guix build fossil)
98 ((guix build download)
99 #:select (download-method-enabled? url-fetch))
100 (guix build download-nar))
101 (or (and (download-method-enabled? 'upstream)
102 (or (and #$tarball-url
103 (url-fetch #$tarball-url #$output))
104 (fossil-fetch
105 #$(if scheme-of-uri uri (local-file uri))
106 #$check-in
107 #$output
108 #:fossil-command
109 #+(file-append fossil "/bin/fossil"))))
110 (and (download-method-enabled? 'nar)
111 (download-nar #$output))))))))
112 (mlet %store-monad ((guile (package->derivation guile system)))
113 (gexp->derivation tarball-name build
114 #:leaked-env-vars '("http_proxy" "https_proxy"
115 "COLUMNS" "USER")
116 #:env-vars (match (getenv "GUIX_DOWNLOAD_METHODS")
117 (#f '())
118 (value
119 `(("GUIX_DOWNLOAD_METHODS" . ,value))))
120 #:system system
121 #:hash-algo hash-algo
122 #:hash hash
123 #:recursive? #t
124 #:guile-for-build guile
125 #:local-build? #t))))