projects/guix·blob java-team · refs

686 lines · 29.5 KiB

1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2017, 2018, 2019, 2020 Marius Bakke <[email protected]>
3;;; Copyright © 2017 Rutger Helling <[email protected]>
4;;; Copyright © 2020, 2022 Tobias Geerinckx-Rice <[email protected]>
5;;; Copyright © 2021 Greg Hogan <[email protected]>
6;;; Copyright © 2022 Ricardo Wurmus <[email protected]>
7;;; Copyright © 2024 Janneke Nieuwenhuizen <[email protected]>
8;;; Copyright © 2025 Maxim Cournoyer <[email protected]>
9;;; Copyright © 2025 Zheng Junjie <[email protected]>
10;;; Copyright © 2026 Foster Hangdaan <[email protected]>
11;;;
12;;; This file is part of GNU Guix.
13;;;
14;;; GNU Guix is free software; you can redistribute it and/or modify it
15;;; under the terms of the GNU General Public License as published by
16;;; the Free Software Foundation; either version 3 of the License, or (at
17;;; your option) any later version.
18;;;
19;;; GNU Guix is distributed in the hope that it will be useful, but
20;;; WITHOUT ANY WARRANTY; without even the implied warranty of
21;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22;;; GNU General Public License for more details.
23;;;
24;;; You should have received a copy of the GNU General Public License
25;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
26
27(define-module (gnu packages storage)
28 #:use-module ((guix licenses) #:prefix license:)
29 #:use-module (gnu packages admin)
30 #:use-module (gnu packages assembly)
31 #:use-module (gnu packages authentication)
32 #:use-module (gnu packages autotools)
33 #:use-module (gnu packages backup)
34 #:use-module (gnu packages base)
35 #:use-module (gnu packages bash)
36 #:use-module (gnu packages bdw-gc)
37 #:use-module (gnu packages boost)
38 #:use-module (gnu packages bootstrap)
39 #:use-module (gnu packages check)
40 #:use-module (gnu packages commencement)
41 #:use-module (gnu packages compression)
42 #:use-module (gnu packages compression)
43 #:use-module (gnu packages crypto)
44 #:use-module (gnu packages cryptsetup)
45 #:use-module (gnu packages curl)
46 #:use-module (gnu packages databases)
47 #:use-module (gnu packages disk)
48 #:use-module (gnu packages dpdk)
49 #:use-module (gnu packages elf)
50 #:use-module (gnu packages elf)
51 #:use-module (gnu packages gcc)
52 #:use-module (gnu packages gperf)
53 #:use-module (gnu packages icu4c)
54 #:use-module (gnu packages jemalloc)
55 #:use-module (gnu packages libbsd)
56 #:use-module (gnu packages linux)
57 #:use-module (gnu packages linux)
58 #:use-module (gnu packages llvm)
59 #:use-module (gnu packages lua)
60 #:use-module (gnu packages maths)
61 #:use-module (gnu packages ncurses)
62 #:use-module (gnu packages networking)
63 #:use-module (gnu packages nss)
64 #:use-module (gnu packages openldap)
65 #:use-module (gnu packages perl)
66 #:use-module (gnu packages pkg-config)
67 #:use-module (gnu packages pretty-print)
68 #:use-module (gnu packages protobuf)
69 #:use-module (gnu packages python)
70 #:use-module (gnu packages python-build)
71 #:use-module (gnu packages python-xyz)
72 #:use-module (gnu packages rpc)
73 #:use-module (gnu packages sphinx)
74 #:use-module (gnu packages sqlite)
75 #:use-module (gnu packages textutils)
76 #:use-module (gnu packages tls)
77 #:use-module (gnu packages version-control)
78 #:use-module (gnu packages web)
79 #:use-module (gnu packages xml)
80 #:use-module (gnu packages)
81 #:use-module (guix build-system cargo)
82 #:use-module (guix build-system cmake)
83 #:use-module (guix build-system gnu)
84 #:use-module (guix build-system pyproject)
85 #:use-module (guix download)
86 #:use-module (guix gexp)
87 #:use-module (guix git-download)
88 #:use-module (guix packages)
89 #:use-module (guix utils))
90
91(define-public ceph
92 (package
93 (name "ceph")
94 (version "21.0.0")
95 (source (origin
96 (method git-fetch)
97 (uri (git-reference
98 (url "https://github.com/ceph/ceph")
99 (commit (string-append "v" version))
100 ;; There are many source bundled libraries, and the build
101 ;; system does not yet support using dependencies from
102 ;; the system for all of them.
103 (recursive? #t)))
104 (file-name (git-file-name name version))
105 (sha256
106 (base32
107 "13rv8kz0rjnldxs4ldpxhckqn7pf95rr8wlvg9s6nwcvl31iq9cv"))
108 (modules '((guix build utils)))
109 (snippet
110 ;; Delete bundled libraries where feasible.
111 '(for-each delete-file-recursively
112 '( ;; TODO: Unbundle these:
113 ;;"src/isa-l"
114 ;;"src/xxHash"
115 "src/BLAKE3"
116 "src/arrow"
117 "src/c-ares"
118 "src/fmt"
119 "src/googletest"
120 "src/jaegertracing"
121 "src/qatlib"
122 "src/qatzip"
123 "src/spdk"
124 "src/rocksdb"
125 "src/utf8proc"
126 "src/zstd"
127 "systemd")))))
128 (build-system cmake-build-system)
129 (arguments
130 (list
131 #:configure-flags
132 #~(list (string-append "-DCMAKE_INSTALL_RPATH="
133 #$output "/lib" ";" #$output "/lib/ceph")
134 "-DENABLE_GIT_VERSION=OFF"
135 "-DCMAKE_INSTALL_LOCALSTATEDIR=/var"
136 "-DBUILD_SHARED_LIBS=ON"
137 "-DCEPHADM_BUNDLED_DEPENDENCIES=none"
138 "-DWITH_SYSTEM_ARROW=ON"
139 "-DWITH_SYSTEM_BOOST=ON"
140 "-DWITH_SYSTEM_CATCH2=ON"
141 "-DWITH_SYSTEM_FMT=ON"
142 #$@(if (target-x86-64?)
143 #~("-DWITH_SYSTEM_QATLIB=ON"
144 "-DWITH_SYSTEM_QATZIP=ON")
145 #~())
146 "-DWITH_SYSTEM_LIBURING=ON"
147 "-DWITH_SYSTEM_ROCKSDB=ON"
148 "-DWITH_SYSTEM_UTF8PROC=ON"
149 "-DWITH_SYSTEM_ZSTD=ON"
150
151 ;; TODO: Enable these when available in Guix.
152 "-DWITH_MGR=OFF" ;requires python-rook-client
153 "-DWITH_MGR_DASHBOARD_FRONTEND=OFF" ;requires node + nodeenv
154 "-DWITH_BABELTRACE=OFF"
155 "-DWITH_BREAKPAD=OFF"
156 "-DWITH_JAEGER=OFF" ;requires bundled opentelemetry-cpp
157 "-DWITH_LTTNG=OFF"
158 "-DWITH_RADOSGW=OFF" ;requires bundled libkmip and rgw
159 "-DWITH_SPDK=OFF"
160 "-DWITH_RADOSGW_AMQP_ENDPOINT=OFF"
161
162 ;; Use jemalloc instead of tcmalloc.
163 "-DALLOCATOR=jemalloc"
164
165 ;; Don't install systemd unit files.
166 "-DWITH_SYSTEMD=OFF"
167
168 ;; Do not bother building the tests; we are not currently running
169 ;; them, and they do not build with system googletest as of 14.2.5.
170 "-DWITH_TESTS=OFF")
171 ;; FIXME: Some of the tests leak Btrfs subvolumes on Btrfs. See
172 ;; <https://bugs.gnu.org/29674> for details. Disable tests until
173 ;; resolved.
174 #:tests? #f
175 #:phases
176 #~(modify-phases %standard-phases
177 (add-after 'unpack 'unbundle-blake3
178 (lambda _
179 ;; Unbundle Blake3.
180 (substitute* "src/CMakeLists.txt"
181 (("add_subdirectory.*BLAKE3.*") ""))))
182 (add-after 'unpack 'relax-fmt-requirement
183 (lambda _
184 (substitute* "src/CMakeLists.txt"
185 (("11.1.4 REQUIRED")
186 "<12 REQUIRED"))))
187 (add-after 'unpack 'fix-zstd-include
188 (lambda _
189 ;; See <https://tracker.ceph.com/issues/63194>.
190 (substitute* "src/compressor/zstd/ZstdCompressor.h"
191 (("#include \"zstd/lib/zstd.h\"")
192 "#include \"zstd.h\""))))
193 (add-after 'unpack 'set-source-file-times-to-1980
194 (lambda _
195 (let ((circa-1980 (* 10 366 24 60 60)))
196 (for-each (lambda (f) (utime f circa-1980 circa-1980))
197 (find-files "src")))))
198 (add-before 'build 'build-legacy-option-header
199 (lambda _
200 ;; Building this target in parallel causes races (see:
201 ;; <https://tracker.ceph.com/issues/63402>), so build it before
202 ;; the main build without parallelism.
203 (invoke "make" "legacy-option-headers")))
204 (add-after 'unpack 'patch-source
205 (lambda _
206 ;; Injecting the -rpath linker argument in Distutils.cmake
207 ;; doesn't help because the argument is ignored at compile time,
208 ;; in get_python_flags. Instead, use runtime_library_dirs there.
209 (substitute* (find-files "src/pybind" "setup\\.py")
210 (("^( *)libraries=libs \\+ py_libs," all blank)
211 (format #f "~aruntime_library_dirs=[~s],~%~a"
212 blank (string-append #$output "/lib") all)))
213 (substitute* "udev/50-rbd.rules"
214 (("/usr/bin/ceph-rbdnamer")
215 (string-append #$output "/bin/ceph-rbdnamer")))
216 ;; os <-> memstore circular dependency require static library
217 (substitute* "src/os/memstore/CMakeLists.txt"
218 (("add_library\\(memstore" all)
219 (string-append all " STATIC")))))
220 (add-after 'install 'post-install
221 (lambda _
222 (let ((lib (string-append #$output "/lib")))
223 ;; Some libraries have that library in their runpath but
224 ;; it doesn't get installed for some reason.
225 (install-file "../build/lib/libfusestore.so"
226 (string-append #$output "/lib"))
227 ;; Unclear why, but in CMakeLists.txt, this target explicitely
228 ;; sets INSTALL_RPATH to "", which then fails the guix
229 ;; validate-runpath phase.
230 (invoke "patchelf" "--add-rpath" lib
231 (string-append #$output "/bin/ceph-osd")))))
232 (add-after 'install 'wrap-python-scripts
233 (lambda* (#:key inputs #:allow-other-keys)
234 (let* ((scripts '("bin/ceph" "bin/cephfs-top" "sbin/ceph-volume"))
235 (dependencies (map (lambda (input)
236 (assoc-ref inputs input))
237 '("python-prettytable" "python-pyyaml")))
238 (site (lambda (package)
239 (string-append package
240 "/lib/python"
241 #$(version-major+minor
242 (package-version
243 (this-package-input "python")))
244 "/site-packages")))
245 (PYTHONPATH (string-join
246 (map site (cons #$output dependencies))
247 ":")))
248 (for-each (lambda (s)
249 (wrap-program (string-append #$output "/" s)
250 `("GUIX_PYTHONPATH" prefix (,PYTHONPATH))))
251 scripts)))))))
252 (native-inputs
253 (list catch2
254 patchelf
255 pkg-config
256 python
257 python-cython
258 python-setuptools
259 python-sphinx
260 yasm))
261 (inputs
262 (append
263 (if (target-x86-64?)
264 (list qatlib qatzip)
265 '())
266 (list `(,apache-thrift "lib")
267 `(,apache-thrift "include")
268 `(,apache-arrow "lib")
269 `(,util-linux "lib")
270 bash-minimal
271 boost
272 cryptsetup-minimal
273 curl
274 eudev
275 expat
276 fcgi
277 fmt-11
278 fuse
279 icu4c
280 jemalloc
281 keyutils
282 leveldb
283 libaio
284 libatomic-ops
285 libcap ;for src/extblkdev
286 libcap-ng
287 libblake3
288 libnbd
289 libnl
290 librdkafka
291 liburing
292 lmdb
293 lua
294 lz4
295 ncurses
296 nss
297 oath-toolkit
298 openldap
299 openssl
300 python
301 python-prettytable ;used by ceph_daemon.py
302 python-pyyaml ;from python-common/setup.py
303 rapidjson
304 rdma-core
305 rocksdb-for-ceph
306 snappy
307 sqlite
308 utf8proc
309 util-linux
310 xfsprogs
311 zlib
312 `(,zstd "lib"))))
313 (home-page "https://ceph.io/en/")
314 (synopsis "Distributed object store and file system")
315 (description
316 "Ceph is a distributed storage system designed for reliability and
317performance. It provides network-based block devices (RBD), a POSIX
318compliant file system (CephFS), and offers compatibility with various
319storage protocols (S3, NFS, and others) through the RADOS gateway.")
320 ;; The Ceph libraries are LGPL2.1 and most of the utilities fall under
321 ;; GPL2. The installed erasure code plugins are BSD-3 licensed and do
322 ;; not use the GPL code. The source archive includes a number of files
323 ;; carrying other licenses; consult COPYING for more information. Note
324 ;; that COPYING does not cover third-party bundled software.
325 (license (list license:lgpl2.1 license:gpl2 ;some files are 'or later'
326 license:cc-by-sa3.0 ;documentation
327 license:bsd-3 ;isa-l,jerasure,++
328 license:expat)))) ;java bindings
329
330(define-public libnbd
331 (package
332 (name "libnbd")
333 (version "1.24.0")
334 (source (origin
335 (method url-fetch)
336 (uri (string-append "https://download.libguestfs.org/" name "/"
337 (version-major+minor version) "-stable/"
338 name "-" version ".tar.gz"))
339
340 (sha256
341 (base32
342 "1vz62w270p23787v1r51rbcfd9lh73b99mcaf7q27pldc7bazggm"))))
343 (build-system gnu-build-system)
344 (arguments
345 ;; The fork-safe-execvpe test fails for unknown reasons (see:
346 ;; <https://gitlab.com/nbdkit/libnbd/-/issues/14>).
347 (list
348 #:configure-flags
349 #~(list (string-append "--with-python-installdir="
350 #$output "/lib/python"
351 #$(package-version (this-package-input
352 "python-minimal"))
353 "/site-packages"))
354 #:make-flags #~(list "XFAIL_TESTS=test-fork-safe-execvpe.sh")
355 #:phases #~(modify-phases %standard-phases
356 (add-after 'unpack 'patch-commands
357 (lambda* (#:key inputs #:allow-other-keys)
358 (substitute* '("lib/utils.c"
359 "sh/nbdsh.in")
360 (("/bin/sh")
361 (search-input-file inputs "bin/sh"))))))))
362 (native-inputs (list pkg-config perl))
363 (inputs (list bash-minimal fuse gnutls libxml2
364 python-minimal)) ;match the python used by libxml2
365 (home-page "https://gitlab.com/nbdkit/libnbd")
366 (synopsis "Network Block Device client library in userspace")
367 (description "@acronym{NBD, Network Block Device} is a protocol
368for accessing block devices (hard disks and disk-like things) over a network.
369This is the NBD client library in userspace, a simple library for writing NBD
370clients. The key features are:
371@itemize
372@item Synchronous API for ease of use.
373@item Asynchronous API for writing non-blocking, multithreaded clients.
374@item High performance.
375@item Minimal dependencies for the basic library.
376@item Well-documented, stable API.
377@item Bindings in several programming languages.
378@item Shell (nbdsh) for command line and scripting.
379@item Copying tool (nbdcopy) for high performance copying and streaming.
380@item Hexdump tool (nbddump) to print NBD content.
381@item Query tool (nbdinfo) to query NBD servers.
382@item FUSE support (nbdfuse) to mount NBD in the local file system.
383@item Linux ublk support (nbdublk) to create the userspace block device.
384@end itemize")
385 (license license:lgpl2.1+)))
386
387(define-public spdk
388 (package
389 (name "spdk")
390 (version "25.09")
391 (source
392 (origin
393 (method git-fetch)
394 (uri (git-reference
395 (url "https://github.com/spdk/spdk")
396 (commit (string-append "v" version))))
397 (sha256
398 (base32 "1x2nrg4qjilym18shb792593gn1bwihzaq19bxms06mmw40x4s6n"))))
399 (build-system gnu-build-system)
400 (arguments
401 (list
402 ;; FIXME: Issue with dpdk: error: depends on
403 ;; 'libspdk_env_dpdk_rpc.so.6.0', which cannot be found in RUNPATH
404 #:tests? #f
405 #:imported-modules
406 (append %default-gnu-imported-modules
407 %pyproject-build-system-modules)
408 #:validate-runpath? #f
409 #:modules '((guix build gnu-build-system)
410 (guix build utils)
411 ((guix build pyproject-build-system) #:prefix py:)
412 (ice-9 rdelim)
413 (ice-9 popen))
414 #:configure-flags
415 #~(list "--with-shared"
416 (string-append "--prefix=" #$output)
417 (string-append "--with-dpdk=" #$(this-package-input "dpdk")))
418 #:phases
419 #~(modify-phases %standard-phases
420 (add-after 'unpack 'substitute-git-submodules
421 (lambda _
422 (rmdir "isa-l")
423 (symlink #$(package-source (this-package-input "isa-l")) "isa-l")))
424 (add-after 'substitute-git-submodules 'skip-python-make-subdir
425 ;; SPDK's Makefile calls 'pip install' for the python subdir, but
426 ;; pip 25+ crashes in the sandbox (SSL cert path not found at
427 ;; import time). Remove python from DIRS-y and install the package
428 ;; ourselves in install-python-package below.
429 (lambda _
430 (substitute* "Makefile"
431 (("DIRS-y \\+= python") ""))))
432 (replace 'configure
433 (lambda* (#:key configure-flags #:allow-other-keys)
434 (substitute* "configure"
435 (("#! /bin/sh") (string-append "#!" (which "sh"))))
436 (setenv "CC" #$(cc-for-target))
437 (setenv "CFLAGS" "-mssse3")
438 (setenv "CONFIG_SHELL" (which "bash"))
439 (setenv "LDFLAGS" "-lbsd")
440 (setenv "SHELL" (which "bash"))
441 (apply invoke "./configure" configure-flags)))
442 (add-before 'install 'set-install-environment
443 ;; same as ceph
444 (lambda _
445 (let ((py3sitedir
446 (string-append #$output "/lib/python"
447 #$(version-major+minor
448 (package-version python))
449 "/site-packages")))
450 (setenv "PYTHONPATH" py3sitedir))))
451 (add-after 'install 'patchelf
452 (lambda* (#:key inputs outputs #:allow-other-keys)
453 (let* ((binaries '("iscsi_tgt" "nvmf_tgt"
454 "spdk_dd" "spdk_lspci" "spdk_nvme_discover"
455 "spdk_tgt" "spdk_top" "spdk_trace"
456 "spdk_nvme_identify" "spdk_nvme_perf"
457 "spdk_trace_record" "vhost"))
458 (ld-so (search-input-file inputs #$(glibc-dynamic-linker)))
459 (libs
460 (list
461 (string-append #$(this-package-input "libbsd") "/lib")
462 (string-append #$(this-package-input "libarchive") "/lib")
463 (string-append #$(this-package-input "numactl") "/lib")
464 (string-append #$(gexp-input util-linux "lib") "/lib")
465 (string-append #$(this-package-input "openssl") "/lib")
466 (string-append #$(this-package-input "openlibm") "/lib")
467 (string-append #$(this-package-input "libaio") "/lib")
468 (string-append #$(this-package-input "dpdk") "/lib")
469 (string-append #$(this-package-input "fuse") "/lib")
470 (string-append #$(this-package-input "gcc") "/lib")
471 (string-append #$(this-package-input "glibc") "/lib")
472 (string-append #$(this-package-input "ncurses") "/lib")))
473 (rpath* (apply string-append (map (lambda (l) (string-append l ":")) libs))))
474 (for-each
475 (lambda (b)
476 (let ((file (string-append #$output "/bin/" b)))
477 (invoke "patchelf" "--set-interpreter" ld-so file)
478 (let* ((pipe (open-pipe* OPEN_READ "patchelf" "--print-rpath" file))
479 (line (read-line pipe)))
480 (and (zero? (close-pipe pipe))
481 (invoke "patchelf" "--set-rpath" (string-append rpath* line)
482 file)))
483 (wrap-program file
484 `("LD_LIBRARY_PATH" ":" prefix (,(string-append #$output "/lib"))))))
485 binaries))))
486 (add-after 'patchelf 'python:wrap
487 (assoc-ref py:%standard-phases 'wrap))
488 (add-before 'python:wrap 'install-python-package
489 ;; Install the SPDK Python package using hatchling + installer,
490 ;; bypassing pip (which crashes in the sandbox due to SSL).
491 ;; spdk/version.py is normally generated by python/Makefile, so
492 ;; we recreate it here from the top-level VERSION file.
493 (lambda* (#:key outputs #:allow-other-keys)
494 (invoke "python" "-c"
495 (string-append
496 "v=open('VERSION').read().strip();"
497 "p=v.split('.');"
498 "ver=p[0]+'.'+p[1]+(('.'+p[2]) if len(p)>2 and p[2]!='0' else '');"
499 "open('python/spdk/version.py','w')"
500 ".write(\"__version__ = '\"+ver+\"'\\n\")"))
501 ;; ZIP format requires timestamps >= 1980; Guix normalizes
502 ;; source timestamps to epoch 0, so clamp SOURCE_DATE_EPOCH.
503 (setenv "SOURCE_DATE_EPOCH" "315532800")
504 (with-directory-excursion "python"
505 (invoke "python" "-m" "hatchling" "build" "-t" "wheel")
506 (let ((wheel (car (find-files "dist" "\\.whl$"))))
507 (invoke "python" "-m" "installer"
508 "--prefix" #$output wheel)))))
509 (add-after 'python:wrap 'wrap-python-scripts
510 (lambda* (#:key inputs #:allow-other-keys)
511 (let* ((scripts '("bin/spdk-cli" "bin/spdk-rpc"))
512 (dependencies (map (lambda (input)
513 (assoc-ref inputs input))
514 '("python-configshell-fb")))
515 (python-version #$(version-major+minor (package-version python)))
516 (sitedir (lambda (package)
517 (string-append package "/lib/python"
518 python-version "/site-packages")))
519 (PYTHONPATH (string-join (map sitedir (cons #$output dependencies)) ":")))
520 (for-each (lambda (executable)
521 (wrap-program (string-append #$output "/" executable)
522 `("GUIX_PYTHONPATH" ":" prefix (,PYTHONPATH))))
523 scripts)))))))
524 (native-inputs
525 (list autoconf
526 automake
527 patchelf
528 pkg-config
529 python-installer
530 python-wrapper))
531 (inputs
532 (list cunit
533 dpdk
534 elfutils
535 fuse
536 (list gcc "lib")
537 glibc
538 isa-l
539 jansson
540 libaio
541 libarchive
542 libbsd
543 libnl
544 libpcap
545 ncurses
546 numactl
547 openlibm
548 openssl
549 python-configshell-fb
550 python-hatchling ;build backend for python/pyproject.toml
551 (list util-linux "lib") ;; <uuid.h>
552 zlib
553 zstd))
554 (home-page "https://spdk.io/")
555 (synopsis "Storage Performance Development Kit")
556 (description
557 "@acronym{Storage Performance Development Kit, SPDK} provides a set of
558tools and libraries for writing high performance,scalable, user-mode storage
559applications.
560
561Note: the @command{spdk-mcp} binary requires the optional @code{mcp[cli]}
562Python dependency, and @command{spdk-sma} requires @code{grpcio} and
563@code{protobuf}. These are not currently packaged in Guix.")
564 (license license:bsd-3)))
565
566(define-public swapspace
567 (package
568 (name "swapspace")
569 (version "1.18.1")
570 (source (origin
571 (method git-fetch)
572 (uri (git-reference
573 (url "https://github.com/Tookmund/swapspace")
574 (commit (string-append "v" version))))
575 (file-name (git-file-name name version))
576 (sha256
577 (base32
578 "1cpmrmwfvzkjll82b6gjnyrmpz69hfx98jf6xx463va7bncdvcra"))))
579 (build-system gnu-build-system)
580 (native-inputs (list autoconf automake))
581 (home-page "https://github.com/Tookmund/swapspace")
582 (synopsis "Dynamic swap manager for Linux")
583 (description "This package provides a dynamic swap manager for Linux.")
584 (license license:gpl2+)))
585
586(define-public garage
587 (package
588 (name "garage")
589 (version "2.4.0")
590 (source
591 (origin
592 (method git-fetch)
593 (uri (git-reference
594 (url "https://git.deuxfleurs.fr/Deuxfleurs/garage.git")
595 (commit (string-append "v" version))))
596 (file-name (git-file-name name version))
597 (sha256
598 (base32 "0v93gl1gppr7llwjgv3x6hyhsc5pj3drnlhcc7xhnza1m6lz16fl"))
599 (snippet
600 #~(begin (use-modules (guix build utils))
601 (delete-file-recursively "doc")))))
602 (build-system cargo-build-system)
603 (arguments
604 (list
605 ;; Disable default features and explicitly set them instead.
606 #:cargo-build-flags `(list "--no-default-features")
607 ;; The tests fail to compile without the '--release' flag.
608 #:cargo-test-flags `(list "--release" "--no-default-features")
609 #:cargo-install-paths ''("src/garage")
610 #:features '(list "system-libs"
611 "k2v"
612 "kubernetes-discovery"
613 "lmdb"
614 "metrics"
615 "sqlite"
616 "syslog"
617 "telemetry-otlp")
618 #:install-source? #f
619 #:modules
620 '((guix build cargo-build-system)
621 (guix build utils)
622 (ice-9 match))
623 #:phases
624 #~(modify-phases %standard-phases
625 ;; The 'check phase doesn't honor #:features
626 (replace 'check
627 (lambda* (#:key features cargo-test-flags #:allow-other-keys
628 #:rest args)
629 (apply (assoc-ref %standard-phases 'check)
630 (append
631 args
632 (list #:cargo-test-flags
633 (append cargo-test-flags
634 (list "--features"
635 (string-join features))))))))
636 ;; The 'install phase can't pass '--no-default-features'
637 (replace 'install
638 (lambda* (#:key cargo-install-paths features #:allow-other-keys)
639 (mkdir-p #$output)
640 (setenv "CARGO_TARGET_DIR" "./target")
641 (for-each
642 (lambda (path)
643 (invoke "cargo" "install" "--offline" "--no-track"
644 "--path" path "--root" #$output
645 "--no-default-features"
646 "--features" (string-join features)))
647 (if (null? cargo-install-paths)
648 '(".")
649 cargo-install-paths))))
650 (add-after 'install 'install-completions
651 (lambda* (#:key native-inputs #:allow-other-keys)
652 (for-each
653 (match-lambda
654 ((shell . path)
655 (mkdir-p (in-vicinity #$output (dirname path)))
656 (let ((binary
657 (if #$(%current-target-system)
658 (search-input-file native-inputs "bin/garage")
659 (in-vicinity #$output "bin/garage"))))
660 (with-output-to-file (in-vicinity #$output path)
661 (lambda _
662 (invoke binary "completions" shell))))))
663 '(("bash" . "share/bash-completion/completions/garage")
664 ("elvish" . "share/elvish/lib/garage")
665 ("fish" . "share/fish/vendor_completions.d/garage.fish")
666 ("zsh" . "share/zsh/site-functions/_garage"))))))))
667 (native-inputs
668 (append (if (%current-target-system)
669 (list this-package)
670 '())
671 (list nss-certs-for-test
672 pkg-config
673 protobuf)))
674 (inputs
675 (cons* libsodium
676 lmdb
677 openssl
678 sqlite
679 `(,zstd "lib")
680 (cargo-inputs 'garage)))
681 (home-page "https://garagehq.deuxfleurs.fr/")
682 (synopsis "S3-compatible, distributed object storage designed for self-hosting")
683 (description "Garage is a lightweight, geo-distributed data store that
684implements the @url{https://docs.aws.amazon.com/AmazonS3/latest/API/Welcome.html,
685 Amazon S3} object storage protocol, with a focus on simplicity and resiliency.")
686 (license license:agpl3)))