projects/guix·blob ruby-team · refs

1067 lines · 45.6 KiB

1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2016 David Thompson <[email protected]>
3;;; Copyright © 2018, 2023 Efraim Flashner <[email protected]>
4;;; Copyright © 2019, 2020 Tobias Geerinckx-Rice <[email protected]>
5;;; Copyright © 2019, 2020, 2021, 2023 Maxim Cournoyer <[email protected]>
6;;; Copyright © 2020 Michael Rohleder <[email protected]>
7;;; Copyright © 2020 Katherine Cox-Buday <[email protected]>
8;;; Copyright © 2020 Jesse Dowell <[email protected]>
9;;; Copyright © 2021, 2022 Oleg Pykhalov <[email protected]>
10;;; Copyright © 2022 Pierre Langlois <[email protected]>
11;;; Copyright © 2024 Nicolas Graves <[email protected]>
12;;; Copyright © 2025 Artyom V. Poptsov <[email protected]>
13;;; Copyright © 2025 Vinicius Monego <[email protected]>
14;;; Copyright © 2025 John Kehayias <[email protected]>
15;;; Copyright © 2025 Arthur Rodrigues <[email protected]>
16;;;
17;;; This file is part of GNU Guix.
18;;;
19;;; GNU Guix is free software; you can redistribute it and/or modify it
20;;; under the terms of the GNU General Public License as published by
21;;; the Free Software Foundation; either version 3 of the License, or (at
22;;; your option) any later version.
23;;;
24;;; GNU Guix is distributed in the hope that it will be useful, but
25;;; WITHOUT ANY WARRANTY; without even the implied warranty of
26;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27;;; GNU General Public License for more details.
28;;;
29;;; You should have received a copy of the GNU General Public License
30;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
31
32(define-module (gnu packages docker)
33 #:use-module ((guix licenses) #:prefix license:)
34 #:use-module (gnu packages)
35 #:use-module (guix packages)
36 #:use-module (guix download)
37 #:use-module (guix gexp)
38 #:use-module (guix git-download)
39 #:use-module (guix build-system cmake)
40 #:use-module (guix build-system gnu)
41 #:use-module (guix build-system go)
42 #:use-module (guix build-system pyproject)
43 #:use-module (guix utils)
44 #:use-module (gnu packages autotools)
45 #:use-module (gnu packages base)
46 #:use-module (gnu packages check)
47 #:use-module (gnu packages containers)
48 #:use-module (gnu packages compression)
49 #:use-module (gnu packages glib)
50 #:use-module (gnu packages golang)
51 #:use-module (gnu packages golang-build)
52 #:use-module (gnu packages golang-check)
53 #:use-module (gnu packages golang-web)
54 #:use-module (gnu packages golang-xyz)
55 #:use-module (gnu packages linux)
56 #:use-module (gnu packages networking)
57 #:use-module (gnu packages pkg-config)
58 #:use-module (gnu packages prometheus)
59 #:use-module (gnu packages python)
60 #:use-module (gnu packages python-build)
61 #:use-module (gnu packages python-crypto)
62 #:use-module (gnu packages python-web)
63 #:use-module (gnu packages python-xyz)
64 #:use-module (gnu packages version-control))
65
66;; Note - when changing Docker versions it is important to update the versions
67;; of several associated packages (docker-libnetwork and go-sctp).
68(define %docker-version "20.10.27")
69
70(define-public go-github-com-compose-spec-compose-go-v2
71 (package
72 (name "go-github-com-compose-spec-compose-go-v2")
73 (version "2.9.0")
74 (source
75 (origin
76 (method git-fetch)
77 (uri (git-reference
78 (url "https://github.com/compose-spec/compose-go")
79 (commit (string-append "v" version))))
80 (file-name (git-file-name name version))
81 (sha256
82 (base32 "18z626vjd0cbqs130nsqhx0vfr6hxarvwgrw5acydy7hfv594aiq"))
83 (modules '((guix build utils)))
84 (snippet
85 #~(begin
86 ;; Build fails when this file is kept: Code in directory
87 ;; /tmp/<...>/src/github.com/compose-spec/compose-go/v2 expects
88 ;; import "github.com/compose-spec/compose-go"
89 (delete-file "package.go")))))
90 (build-system go-build-system)
91 (arguments
92 (list
93 #:skip-build? #t
94 #:embed-files
95 #~(list "applicator"
96 "content"
97 "core"
98 "format"
99 "format-annotation"
100 "format-assertion"
101 "meta-data"
102 "schema"
103 "unevaluated"
104 "validation")
105 #:import-path "github.com/compose-spec/compose-go/v2"
106 #:test-flags
107 #~(list "-skip" (string-join
108 ;; error decoding 'services[test].environment':
109 ;; environment variable DEBUG is declared with a
110 ;; trailing space
111 (list "TestEnvironmentWhitespace"
112 ;; ports_test.go:80: assertion failed: expected
113 ;; error "Invalid ip address: 127.0.1", got
114 ;; "invalid IP address: 127.0.1"
115 "Test_transformPorts/invalid_IP"
116 ;; types_test.go:190: assertion failed: expected
117 ;; error "Invalid containerPort: 9999999", got
118 ;; "invalid containerPort: 9999999"
119 "TestParsePortConfig")
120 "|"))))
121 (native-inputs
122 (list go-github-com-google-go-cmp
123 go-github-com-stretchr-testify
124 go-gotest-tools-v3))
125 (propagated-inputs
126 (list go-github-com-distribution-reference
127 go-github-com-docker-go-connections
128 go-github-com-docker-go-units
129 go-github-com-go-viper-mapstructure-v2
130 go-github-com-mattn-go-shellwords
131 go-github-com-opencontainers-go-digest
132 go-github-com-santhosh-tekuri-jsonschema-v6
133 go-github-com-sirupsen-logrus
134 go-github-com-xhit-go-str2duration-v2
135 go-go-yaml-in-yaml-v3
136 go-golang-org-x-sync
137 go-golang-org-x-text))
138 (home-page "https://compose-spec.io/")
139 (synopsis "Reference library for parsing and loading Compose YAML files")
140 (description
141 "This package provides a Golang reference library for parsing and
142loading Compose files as specified by the
143@url{https://github.com/compose-spec/compose-spec, Compose specification}.")
144 (license license:asl2.0)))
145
146(define-public go-github-com-docker-go-events
147 (package
148 (name "go-github-com-docker-go-events")
149 (version "0.0.0-20250808211157-605354379745")
150 (source
151 (origin
152 (method git-fetch)
153 (uri (git-reference
154 (url "https://github.com/docker/go-events")
155 (commit (go-version->git-ref version))))
156 (file-name (git-file-name name version))
157 (sha256
158 (base32 "0q3ylzyl670m3an32nhb0l5bsc3f4d9b963x3pjwsc94brg9l5qp"))))
159 (build-system go-build-system)
160 (arguments
161 (list
162 #:import-path "github.com/docker/go-events"))
163 (propagated-inputs
164 (list go-github-com-sirupsen-logrus))
165 (home-page "https://github.com/docker/go-events")
166 (synopsis "Composable event distribution for Golang")
167 (description
168 "This package implements a composable event distribution library,
169originally created to implement the notifications in
170@url{https://github.com/distribution/distribution/blob/v3.0.0/docs/content/about/notifications.md,
171Docker Registry 2}.")
172 (license license:asl2.0)))
173
174(define-public go-github-com-docker-go-metrics
175 (package
176 (name "go-github-com-docker-go-metrics")
177 (version "0.0.1")
178 (source
179 (origin
180 (method git-fetch)
181 (uri (git-reference
182 (url "https://github.com/docker/go-metrics")
183 (commit (string-append "v" version))))
184 (file-name (git-file-name name version))
185 (sha256
186 (base32 "1b6f1889chmwlsgrqxylnks2jic16j2dqhsdd1dvaklk48ky95ga"))))
187 (build-system go-build-system)
188 (arguments
189 (list
190 #:import-path "github.com/docker/go-metrics"))
191 (propagated-inputs (list go-github-com-prometheus-client-golang))
192 (home-page "https://github.com/docker/go-metrics")
193 (synopsis "Go library for metrics collection from Docker projects")
194 (description
195 "This package is a small wrapper around the Prometheus Go client to help
196enforce convention and best practices for metrics collection in Docker
197projects.")
198 (license (list license:asl2.0 license:cc-by-sa4.0))))
199
200(define-public go-github-com-moby-policy-helpers
201 (package
202 (name "go-github-com-moby-policy-helpers")
203 (version "0.0.0-20260507153417-a39d60132186")
204 (source
205 (origin
206 (method git-fetch)
207 (uri (git-reference
208 (url "https://github.com/moby/policy-helpers")
209 (commit (go-version->git-ref version))))
210 (file-name (git-file-name name version))
211 (sha256
212 (base32 "12fa602jianip7dg98f2i9i686s2a9bsclw8sqxw1ac1v19qlqr8"))
213 (modules '((guix build utils)))
214 (snippet '(delete-file-recursively "vendor"))))
215 (build-system go-build-system)
216 (arguments
217 (list
218 #:embed-files #~(list ".*\\.json")
219 #:import-path "github.com/moby/policy-helpers"))
220 (native-inputs
221 (list go-github-com-stretchr-testify))
222 (propagated-inputs
223 (list go-github-com-containerd-containerd-v2
224 go-github-com-containerd-errdefs
225 go-github-com-containerd-platforms
226 go-github-com-distribution-reference
227 go-github-com-gofrs-flock
228 go-github-com-in-toto-in-toto-golang
229 go-github-com-opencontainers-go-digest
230 go-github-com-opencontainers-image-spec
231 go-github-com-pkg-errors
232 go-github-com-sigstore-protobuf-specs
233 go-github-com-sigstore-sigstore
234 go-github-com-sigstore-sigstore-go
235 go-github-com-theupdateframework-go-tuf-v2
236 go-golang-org-x-sync))
237 (home-page "https://github.com/moby/policy-helpers")
238 (synopsis "Policy helpers for Docker")
239 (description "This package provides a policy helpers for Moby (Docker)
240and BuildKit. It is a work in progress.")
241 (license license:asl2.0)))
242
243(define-public python-docker
244 (package
245 (name "python-docker")
246 (version "7.1.0")
247 (source
248 (origin
249 (method git-fetch)
250 (uri (git-reference
251 (url "https://github.com/docker/docker-py")
252 (commit version)))
253 (file-name (git-file-name name version))
254 (sha256
255 (base32 "1dd4p0xfv6vja4mgzwn2yfyna7vi7bc1pr5f59jg9yd4nxj96kmj"))))
256 (build-system pyproject-build-system)
257 (arguments
258 (list
259 ;; Integration tests need a running Docker daemon.
260 #:test-flags #~(list "--ignore" "tests/integration")))
261 (native-inputs (list python-hatch-vcs python-hatchling python-pytest))
262 (inputs
263 (list python-requests python-urllib3))
264 (propagated-inputs
265 (list python-paramiko ;adds SSH support
266 python-websocket-client))
267 (home-page "https://github.com/docker/docker-py/")
268 (synopsis "Python client for Docker")
269 (description "Docker-Py is a Python client for the Docker container
270management tool.")
271 (license license:asl2.0)))
272
273;; Needed for old v1 of docker-compose; remove once Docker is updated to a
274;; more recent version which has the command "docker compose" built-in.
275(define-public python-docker-5
276 (package
277 (inherit python-docker)
278 (name "python-docker")
279 (version "5.0.3")
280 (source
281 (origin
282 (method git-fetch)
283 (uri (git-reference
284 (url "https://github.com/docker/docker-py")
285 (commit version)))
286 (file-name (git-file-name name version))
287 (sha256
288 (base32 "0m5ifgxdhcf7yci0ncgnxjas879sksrf3im0fahs573g268farz9"))))
289 (build-system pyproject-build-system)
290 ;; Integration tests need a running Docker daemon.
291 (arguments (list #:tests? #f))
292 (native-inputs (list python-setuptools))
293 (inputs (modify-inputs inputs
294 (prepend python-six)
295 (delete "python-urllib3")))
296 (propagated-inputs
297 (modify-inputs propagated-inputs
298 (prepend python-docker-pycreds python-urllib3-1.26)))))
299
300;; Needed for old v1 of docker-compose; remove once Docker is updated to a
301;; more recent version which has the command "docker compose" built-in, see:
302;; <https://codeberg.org/guix/guix/milestone/30347>.
303(define-public python-dockerpty
304 (package
305 (name "python-dockerpty")
306 (version "0.4.1")
307 (source
308 (origin
309 (method url-fetch)
310 (uri (pypi-uri "dockerpty" version))
311 (sha256
312 (base32
313 "1kjn64wx23jmr8dcc6g7bwlmrhfmxr77gh6iphqsl39sayfxdab9"))))
314 (build-system pyproject-build-system)
315 (arguments
316 (list #:tests? #f)) ; XXX: Requires outdated python-expects
317 (native-inputs
318 (list python-setuptools python-six))
319 (home-page "https://github.com/d11wtq/dockerpty")
320 (synopsis "Python library to use the pseudo-TTY of a Docker container")
321 (description "Docker PTY provides the functionality needed to operate the
322pseudo-terminal (PTY) allocated to a Docker container using the Python
323client.")
324 (license license:asl2.0)))
325
326;;; TODO: This package needs to be updated to its 2.x series, now authored in
327;;; Go.
328(define-public docker-compose
329 (package
330 (name "docker-compose")
331 (version "1.29.2")
332 (source
333 (origin
334 (method url-fetch)
335 (uri (pypi-uri "docker-compose" version))
336 (sha256
337 (base32
338 "1dq9kfak61xx7chjrzmkvbw9mvj9008k7g8q7mwi4x133p9dk32c"))))
339 (build-system pyproject-build-system)
340 ;; TODO: Tests require running Docker daemon.
341 (arguments
342 (list
343 #:tests? #f
344 #:phases
345 #~(modify-phases %standard-phases
346 (add-after 'unpack 'fix-pyyaml
347 (lambda _
348 (substitute* "setup.py"
349 ((", < 6")
350 "")))))))
351 (native-inputs (list python-setuptools))
352 (inputs
353 (list python-cached-property
354 python-distro
355 python-docker-5
356 python-dockerpty
357 python-docopt
358 python-dotenv-0.13.0
359 python-jsonschema-3
360 python-pyyaml
361 python-requests
362 python-six
363 python-texttable
364 python-websocket-client-0.59))
365 (home-page "https://www.docker.com/")
366 (synopsis "Multi-container orchestration for Docker")
367 (description "Docker Compose is a tool for defining and running
368multi-container Docker applications. A Compose file is used to configure an
369application’s services. Then, using a single command, the containers are
370created and all the services are started as specified in the configuration.")
371 (license license:asl2.0)))
372
373(define-public docker-policy-helper
374 (package/inherit go-github-com-moby-policy-helpers
375 (name "docker-policy-helper")
376 (arguments
377 (substitute-keyword-arguments arguments
378 ((#:import-path _) "github.com/moby/policy-helpers/cmd/policy-helper")
379 ((#:install-source? _ #t) #f)
380 ((#:skip-build? _ #t) #f)
381 ((#:tests? _ #t) #f)
382 ((#:unpack-path _ "") "github.com/moby/policy-helpers")
383 ((#:phases phases '%standard-phases)
384 #~(modify-phases #$phases
385 (add-after 'install 'fix-bin-name
386 (lambda _
387 (rename-file (string-append #$output "/bin/policy-helper")
388 (string-append #$output "/bin/docker-policy-helper"))))))))
389 (native-inputs (package-propagated-inputs go-github-com-moby-policy-helpers))
390 (propagated-inputs '())
391 (inputs '())))
392
393(define-public python-docker-pycreds
394 (package
395 (name "python-docker-pycreds")
396 (version "0.4.0")
397 (source
398 (origin
399 (method url-fetch)
400 (uri (pypi-uri "docker-pycreds" version))
401 (sha256
402 (base32
403 "1m44smrggnqghxkqfl7vhapdw89m1p3vdr177r6cq17lr85jgqvc"))))
404 (build-system pyproject-build-system)
405 (arguments
406 (list ; XXX: These tests require docker credentials to run.
407 #:test-flags '(list "--ignore=tests/store_test.py")))
408 (native-inputs
409 (list python-pytest python-setuptools python-wheel))
410 (propagated-inputs
411 (list python-six))
412 (home-page "https://github.com/shin-/dockerpy-creds")
413 (synopsis
414 "Python bindings for the Docker credentials store API")
415 (description
416 "Docker-Pycreds contains the Python bindings for the docker credentials
417store API. It allows programmers to interact with a Docker registry using
418Python without keeping their credentials in a Docker configuration file.")
419 (license license:asl2.0)))
420
421(define-public containerd
422 (package
423 (name "containerd")
424 (version "1.6.22")
425 (source
426 (origin
427 (method git-fetch)
428 (uri (git-reference
429 (url "https://github.com/containerd/containerd")
430 (commit (string-append "v" version))))
431 (file-name (git-file-name name version))
432 (sha256
433 (base32 "1m31y00sq2m76m1jiq4znws8gxbgkh5adklvqibxiz1b96vvwjk8"))
434 (patches
435 (search-patches "containerd-create-pid-file.patch"
436 "containerd-fix-includes.patch"))))
437 (build-system go-build-system)
438 (arguments
439 (let ((make-flags #~(list (string-append "VERSION=" #$version)
440 (string-append "DESTDIR=" #$output)
441 "PREFIX="
442 "REVISION=0")))
443 (list
444 #:import-path "github.com/containerd/containerd"
445 ;; XXX: This package contains full vendor, tests fail when run with
446 ;; "...", limit to the project's root. Try to unvendor.
447 #:test-subdirs #~(list ".")
448 #:phases
449 #~(modify-phases %standard-phases
450 (add-after 'unpack 'patch-paths
451 (lambda* (#:key inputs import-path outputs #:allow-other-keys)
452 (with-directory-excursion (string-append "src/" import-path)
453 (substitute* "runtime/v1/linux/runtime.go"
454 (("defaultRuntime[ \t]*=.*")
455 (string-append "defaultRuntime = \""
456 (search-input-file inputs "/sbin/runc")
457 "\"\n"))
458 (("defaultShim[ \t]*=.*")
459 (string-append "defaultShim = \""
460 (assoc-ref outputs "out")
461 "/bin/containerd-shim\"\n")))
462 (substitute* "pkg/cri/config/config_unix.go"
463 (("DefaultRuntimeName: \"runc\"")
464 (string-append "DefaultRuntimeName: \""
465 (search-input-file inputs "/sbin/runc")
466 "\""))
467 ;; ContainerdConfig.Runtimes
468 (("\"runc\":")
469 (string-append "\""
470 (search-input-file inputs "/sbin/runc")
471 "\":")))
472 (substitute* "vendor/github.com/containerd/go-runc/runc.go"
473 (("DefaultCommand[ \t]*=.*")
474 (string-append "DefaultCommand = \""
475 (search-input-file inputs "/sbin/runc")
476 "\"\n")))
477 (substitute* "vendor/github.com/containerd/continuity/testutil\
478/loopback/loopback_linux.go"
479 (("exec\\.Command\\(\"losetup\"")
480 (string-append "exec.Command(\""
481 (search-input-file inputs "/sbin/losetup")
482 "\"")))
483 (substitute* "archive/compression/compression.go"
484 (("exec\\.LookPath\\(\"unpigz\"\\)")
485 (string-append "\""
486 (search-input-file inputs "/bin/unpigz")
487 "\", error(nil)"))))))
488 (replace 'build
489 (lambda* (#:key import-path #:allow-other-keys)
490 (with-directory-excursion (string-append "src/" import-path)
491 (apply invoke "make" #$make-flags))))
492 (replace 'install
493 (lambda* (#:key import-path #:allow-other-keys)
494 (with-directory-excursion (string-append "src/" import-path)
495 (apply invoke "make" "install" #$make-flags))))))))
496 (inputs
497 (list btrfs-progs libseccomp pigz runc util-linux))
498 (native-inputs
499 (list go pkg-config))
500 (synopsis "Docker container runtime")
501 (description "This package provides the container daemon for Docker.
502It includes image transfer and storage, container execution and supervision,
503network attachments.")
504 (home-page "https://containerd.io/")
505 (license license:asl2.0)))
506
507;;; Private package that shouldn't be used directly; its purposes is to be
508;;; used as a template for the various packages it contains. It doesn't build
509;;; anyway, as it needs many dependencies that aren't being satisfied.
510(define docker-libnetwork
511 ;; There are no recent release for libnetwork, so choose the last commit of
512 ;; the branch that Docker uses, as can be seen in the 'vendor.conf' Docker
513 ;; source file. NOTE - It is important that this version is kept in sync
514 ;; with the version of Docker being used.
515 (let ((commit "3797618f9a38372e8107d8c06f6ae199e1133ae8")
516 (version (version-major+minor %docker-version))
517 (revision "3"))
518 (package
519 (name "docker-libnetwork")
520 (version (git-version version revision commit))
521 (source (origin
522 (method git-fetch)
523 (uri (git-reference
524 ;; Redirected from github.com/docker/libnetwork.
525 (url "https://github.com/moby/libnetwork")
526 (commit commit)))
527 (file-name (git-file-name name version))
528 (sha256
529 (base32
530 "1km3p6ya9az0ax2zww8wb5vbifr1gj5n9l82i273m9f3z9f2mq2p"))
531 ;; Delete bundled ("vendored") free software source code.
532 (modules '((guix build utils)))
533 (snippet '(delete-file-recursively "vendor"))))
534 (build-system go-build-system)
535 (arguments
536 `(#:import-path "github.com/moby/libnetwork/"))
537 (home-page "https://github.com/moby/libnetwork/")
538 (synopsis "Networking for containers")
539 (description "Libnetwork provides a native Go implementation for
540connecting containers. The goal of @code{libnetwork} is to deliver a robust
541container network model that provides a consistent programming interface and
542the required network abstractions for applications.")
543 (license license:asl2.0))))
544
545(define-public docker-libnetwork-cmd-proxy
546 (package
547 (inherit docker-libnetwork)
548 (name "docker-libnetwork-cmd-proxy")
549 (arguments
550 (list
551 ;; The tests are unsupported on all architectures except x86_64-linux.
552 #:tests? (and (not (%current-target-system)) (target-x86-64?))
553 #:install-source? #f
554 #:import-path "github.com/docker/libnetwork/cmd/proxy"
555 #:unpack-path "github.com/docker/libnetwork"))
556 (native-inputs
557 (list go-github-com-sirupsen-logrus ; for tests.
558 go-github-com-vishvananda-netlink
559 go-github-com-vishvananda-netns
560 go-golang-org-x-crypto
561 go-golang-org-x-sys
562 go-sctp))
563 (synopsis "Docker user-space proxy")
564 (description
565 "This package provides a proxy running in the user space. It is used by
566the built-in registry server of Docker.")
567 (license license:asl2.0)))
568
569;; TODO: Patch out modprobes for ip_vs, nf_conntrack,
570;; brige, nf_conntrack_netlink, aufs.
571(define-public docker
572 (package
573 (name "docker")
574 (version %docker-version)
575 (source
576 (origin
577 (method git-fetch)
578 (uri (git-reference
579 (url "https://github.com/moby/moby")
580 (commit (string-append "v" version))))
581 (file-name (git-file-name name version))
582 (sha256
583 (base32 "017frilx35w3m4dz3n6m2f293q4fq4jrk6hl8f7wg5xs3r8hswvq"))))
584 (build-system gnu-build-system)
585 (arguments
586 (list
587 #:modules
588 '((guix build gnu-build-system)
589 ((guix build go-build-system) #:prefix go:)
590 (guix build union)
591 (guix build utils))
592 #:imported-modules
593 `(,@%default-gnu-imported-modules
594 (guix build union)
595 (guix build go-build-system))
596 #:phases
597 #~(modify-phases %standard-phases
598 (add-after 'unpack 'patch-paths
599 (lambda* (#:key inputs #:allow-other-keys)
600 (substitute* "builder/builder-next/executor_unix.go"
601 (("CommandCandidates:.*runc.*")
602 (string-append "CommandCandidates: []string{\""
603 (search-input-file inputs "/sbin/runc")
604 "\"},\n")))
605 (substitute* "vendor/github.com/containerd/go-runc/runc.go"
606 (("DefaultCommand = .*")
607 (string-append "DefaultCommand = \""
608 (search-input-file inputs "/sbin/runc")
609 "\"\n")))
610 (substitute* "vendor/github.com/containerd/containerd/\
611runtime/v1/linux/runtime.go"
612 (("defaultRuntime[ \t]*=.*")
613 (string-append "defaultRuntime = \""
614 (search-input-file inputs "/sbin/runc")
615 "\"\n"))
616 (("defaultShim[ \t]*=.*")
617 (string-append "defaultShim = \""
618 (search-input-file inputs "/bin/containerd-shim")
619 "\"\n")))
620 (substitute* "daemon/daemon_unix.go"
621 (("DefaultShimBinary = .*")
622 (string-append "DefaultShimBinary = \""
623 (search-input-file inputs "/bin/containerd-shim")
624 "\"\n"))
625 (("DefaultRuntimeBinary = .*")
626 (string-append "DefaultRuntimeBinary = \""
627 (search-input-file inputs "/sbin/runc")
628 "\"\n")))
629 (substitute* "daemon/runtime_unix.go"
630 (("defaultRuntimeName = .*")
631 (string-append "defaultRuntimeName = \""
632 (search-input-file inputs "/sbin/runc")
633 "\"\n")))
634 (substitute* "daemon/config/config.go"
635 (("StockRuntimeName = .*")
636 (string-append "StockRuntimeName = \""
637 (search-input-file inputs "/sbin/runc")
638 "\"\n"))
639 (("DefaultInitBinary = .*")
640 (string-append "DefaultInitBinary = \""
641 (search-input-file inputs "/bin/tini-static")
642 "\"\n")))
643 (substitute* "daemon/config/config_common_unix_test.go"
644 (("expectedInitPath: \"docker-init\"")
645 (string-append "expectedInitPath: \""
646 (search-input-file inputs "/bin/tini-static")
647 "\"")))
648 (substitute* "vendor/github.com/moby/buildkit/executor/\
649runcexecutor/executor.go"
650 (("var defaultCommandCandidates = .*")
651 (string-append "var defaultCommandCandidates = []string{\""
652 (search-input-file inputs "/sbin/runc") "\"}")))
653 (substitute* "vendor/github.com/docker/libnetwork/portmapper/proxy.go"
654 (("var userlandProxyCommandName = .*")
655 (string-append "var userlandProxyCommandName = \""
656 (search-input-file inputs "/bin/proxy")
657 "\"\n")))
658 (substitute* "pkg/archive/archive.go"
659 (("string\\{\"xz")
660 (string-append "string{\"" (search-input-file inputs "/bin/xz"))))
661
662 (let ((source-files (filter (lambda (name)
663 (not (string-contains name "test")))
664 (find-files "." "\\.go$"))))
665 (let-syntax ((substitute-LookPath*
666 (syntax-rules ()
667 ((_ (source-text path) ...)
668 (substitute* source-files
669 (((string-append "\\<exec\\.LookPath\\(\""
670 source-text
671 "\")"))
672 (string-append "\""
673 (search-input-file inputs path)
674 "\", error(nil)")) ...))))
675 (substitute-Command*
676 (syntax-rules ()
677 ((_ (source-text path) ...)
678 (substitute* source-files
679 (((string-append "\\<(re)?exec\\.Command\\(\""
680 source-text
681 "\"") _ re?)
682 (string-append (if re? re? "")
683 "exec.Command(\""
684 (search-input-file inputs path)
685 "\"")) ...)))))
686 (substitute-LookPath*
687 ("containerd" "/bin/containerd")
688 ("ps" "/bin/ps")
689 ("mkfs.xfs" "/sbin/mkfs.xfs")
690 ("lvmdiskscan" "/sbin/lvmdiskscan")
691 ("pvdisplay" "/sbin/pvdisplay")
692 ("blkid" "/sbin/blkid")
693 ("unpigz" "/bin/unpigz")
694 ("iptables" "/sbin/iptables")
695 ("ip6tables" "/sbin/ip6tables")
696 ("iptables-legacy" "/sbin/iptables")
697 ("ip" "/sbin/ip"))
698
699 (substitute-Command*
700 ("modprobe" "/bin/modprobe")
701 ("pvcreate" "/sbin/pvcreate")
702 ("vgcreate" "/sbin/vgcreate")
703 ("lvcreate" "/sbin/lvcreate")
704 ("lvconvert" "/sbin/lvconvert")
705 ("lvchange" "/sbin/lvchange")
706 ("mkfs.xfs" "/sbin/mkfs.xfs")
707 ("xfs_growfs" "/sbin/xfs_growfs")
708 ("mkfs.ext4" "/sbin/mkfs.ext4")
709 ("tune2fs" "/sbin/tune2fs")
710 ("blkid" "/sbin/blkid")
711 ("resize2fs" "/sbin/resize2fs")
712 ("ps" "/bin/ps")
713 ("losetup" "/sbin/losetup")
714 ("uname" "/bin/uname")
715 ("dbus-launch" "/bin/dbus-launch")
716 ("git" "/bin/git")))
717 ;; docker-mountfrom ??
718 ;; docker
719 ;; docker-untar ??
720 ;; docker-applyLayer ??
721 ;; /usr/bin/uname
722 ;; grep
723 ;; apparmor_parser
724
725 ;; Make compilation fail when, in future versions, Docker
726 ;; invokes other programs we don't know about and thus don't
727 ;; substitute.
728 (substitute* source-files
729 ;; Search for Java in PATH.
730 (("\\<exec\\.Command\\(\"java\"")
731 "xxec.Command(\"java\"")
732 ;; Search for AUFS in PATH (mainline Linux doesn't support it).
733 (("\\<exec\\.Command\\(\"auplink\"")
734 "xxec.Command(\"auplink\"")
735 ;; Fail on other unsubstituted commands.
736 (("\\<exec\\.Command\\(\"([a-zA-Z0-9][a-zA-Z0-9_-]*)\""
737 _ executable)
738 (string-append "exec.Guix_doesnt_want_Command(\""
739 executable "\""))
740 (("\\<xxec\\.Command")
741 "exec.Command")
742 ;; Search for ZFS in PATH.
743 (("\\<LookPath\\(\"zfs\"\\)") "LooxPath(\"zfs\")")
744 ;; Do not fail when buildkit-qemu-<target> isn't found.
745 ;; FIXME: We might need to package buildkit and docker's
746 ;; buildx plugin, to support qemu-based docker containers.
747 (("\\<LookPath\\(\"buildkit-qemu-\"") "LooxPath(\"buildkit-qemu-\"")
748 ;; Fail on other unsubstituted LookPaths.
749 (("\\<LookPath\\(\"") "Guix_doesnt_want_LookPath\\(\"")
750 (("\\<LooxPath") "LookPath")))))
751 (add-after 'patch-paths 'delete-failing-tests
752 (lambda _
753 ;; Needs internet access.
754 (delete-file "builder/remotecontext/git/gitutils_test.go")
755 ;; Permission denied.
756 (delete-file "daemon/graphdriver/devmapper/devmapper_test.go")
757 ;; Operation not permitted (idtools.MkdirAllAndChown).
758 (delete-file "daemon/graphdriver/vfs/vfs_test.go")
759 ;; Timeouts after 5 min.
760 (delete-file "plugin/manager_linux_test.go")
761 ;; Operation not permitted.
762 (delete-file "daemon/graphdriver/aufs/aufs_test.go")
763 (delete-file "daemon/graphdriver/btrfs/btrfs_test.go")
764 (delete-file "daemon/graphdriver/overlay/overlay_test.go")
765 (delete-file "daemon/graphdriver/overlay2/overlay_test.go")
766 (delete-file "pkg/chrootarchive/archive_unix_test.go")
767 (delete-file "daemon/container_unix_test.go")
768 ;; This file uses cgroups and /proc.
769 (delete-file "pkg/sysinfo/sysinfo_linux_test.go")
770 ;; This file uses cgroups.
771 (delete-file "runconfig/config_test.go")
772 ;; This file uses /var.
773 (delete-file "daemon/oci_linux_test.go")
774 ;; Signal tests fail in bizarre ways
775 (delete-file "pkg/signal/signal_linux_test.go")))
776 (replace 'configure
777 (lambda _
778 (setenv "DOCKER_BUILDTAGS" "seccomp")
779 (setenv "DOCKER_GITCOMMIT" (string-append "v" #$%docker-version))
780 (setenv "VERSION" (string-append #$%docker-version "-ce"))
781 ;; Automatically use bundled dependencies.
782 ;; TODO: Unbundle - see file "vendor.conf".
783 (setenv "AUTO_GOPATH" "1")
784 ;; Respectively, strip the symbol table and debug
785 ;; information, and the DWARF symbol table.
786 (setenv "LDFLAGS" "-s -w")
787 ;; Make build faster
788 (setenv "GOCACHE" "/tmp")))
789 (add-before 'build 'setup-go-environment
790 (assoc-ref go:%standard-phases 'setup-go-environment))
791 (replace 'build
792 (lambda _
793 ;; Our LD doesn't like the statically linked relocatable things
794 ;; that go produces, so install the dynamic version of
795 ;; dockerd instead.
796 (setenv "BUILDFLAGS" "-trimpath")
797 (invoke "hack/make.sh" "dynbinary")))
798 (replace 'check
799 (lambda* (#:key tests? #:allow-other-keys)
800 (when tests?
801 ;; The build process generated a file because the environment
802 ;; variable "AUTO_GOPATH" was set. Use it.
803 (setenv "GOPATH" (string-append (getcwd) "/.gopath"))
804 ;; ".gopath/src/github.com/docker/docker" is a link to the current
805 ;; directory and chdir would canonicalize to that.
806 ;; But go needs to have the uncanonicalized directory name, so
807 ;; store that.
808 (setenv "PWD" (string-append
809 (getcwd) "/.gopath/src/github.com/docker/docker"))
810 (with-directory-excursion ".gopath/src/github.com/docker/docker"
811 (invoke "hack/test/unit"))
812 (setenv "PWD" #f))))
813 (replace 'install
814 (lambda* (#:key outputs #:allow-other-keys)
815 (let* ((out (assoc-ref outputs "out"))
816 (out-bin (string-append out "/bin")))
817 (install-file "bundles/dynbinary-daemon/dockerd" out-bin)
818 (install-file (string-append "bundles/dynbinary-daemon/dockerd-"
819 (getenv "VERSION"))
820 out-bin)))))))
821 (inputs
822 (list btrfs-progs
823 containerd ; for containerd-shim
824 coreutils
825 dbus
826 docker-libnetwork-cmd-proxy
827 e2fsprogs
828 git
829 iproute
830 iptables
831 kmod
832 libseccomp
833 pigz
834 procps
835 runc
836 util-linux
837 lvm2
838 tini
839 xfsprogs-5.9
840 xz))
841 (native-inputs
842 (list eudev ; TODO: Should be propagated by lvm2 (.pc -> .pc)
843 go-1.21 gotestsum pkg-config))
844 (synopsis "Container component library and daemon")
845 (description "This package provides a framework to assemble specialized
846container systems. It includes components for orchestration, image
847management, secret management, configuration management, networking,
848provisioning etc.")
849 (home-page "https://mobyproject.org/")
850 (license license:asl2.0)))
851
852(define-public docker-cli
853 (package
854 (name "docker-cli")
855 (version %docker-version)
856 (source
857 (origin
858 (method git-fetch)
859 (uri (git-reference
860 (url "https://github.com/docker/cli")
861 (commit (string-append "v" version))))
862 (file-name (git-file-name name version))
863 (sha256
864 (base32 "0szwaxiasy77mm90wj2qg747zb9lyiqndg5halg7qbi41ng6ry0h"))))
865 (build-system go-build-system)
866 (arguments
867 `(#:import-path "github.com/docker/cli"
868 ;; TODO: Tests require a running Docker daemon.
869 #:tests? #f
870 #:phases
871 (modify-phases %standard-phases
872 (add-before 'build 'setup-environment-2
873 (lambda _
874 ;; Respectively, strip the symbol table and debug
875 ;; information, and the DWARF symbol table.
876 (setenv "LDFLAGS" "-s -w")
877
878 ;; Make sure "docker -v" prints a usable version string.
879 (setenv "VERSION" ,%docker-version)
880
881 ;; Make build reproducible.
882 (setenv "BUILDTIME" "1970-01-01 00:00:01.000000000+00:00")
883 (symlink "src/github.com/docker/cli/scripts" "./scripts")
884 (symlink "src/github.com/docker/cli/docker.Makefile" "./docker.Makefile")))
885 (replace 'build
886 (lambda _
887 (setenv "GO_LINKMODE" "dynamic")
888 (invoke "./scripts/build/binary")))
889 (replace 'check
890 (lambda* (#:key make-flags tests? #:allow-other-keys)
891 (setenv "PATH" (string-append (getcwd) "/build:" (getenv "PATH")))
892 (when tests?
893 ;; Use the newly-built docker client for the tests.
894 (with-directory-excursion "src/github.com/docker/cli"
895 ;; TODO: Run test-e2e as well?
896 (apply invoke "make" "-f" "docker.Makefile" "test-unit"
897 (or make-flags '()))))))
898 (replace 'install
899 (lambda* (#:key outputs #:allow-other-keys)
900 (let* ((out (assoc-ref outputs "out"))
901 (out-bin (string-append out "/bin"))
902 (etc (string-append out "/etc")))
903 (with-directory-excursion "src/github.com/docker/cli/contrib/completion"
904 (install-file "bash/docker"
905 (string-append etc "/bash_completion.d"))
906 (install-file "fish/docker.fish"
907 (string-append etc "/fish/completions"))
908 (install-file "zsh/_docker"
909 (string-append etc "/zsh/site-functions")))
910 (install-file "build/docker" out-bin)))))))
911 (native-inputs
912 (list go libltdl pkg-config))
913 (synopsis "Command line interface to Docker")
914 (description "This package provides a command line interface to Docker.")
915 (home-page "https://www.docker.com/")
916 (license license:asl2.0)))
917
918(define-public cqfd
919 (package
920 (name "cqfd")
921 (version "5.6.0")
922 (source (origin
923 (method git-fetch)
924 (uri (git-reference
925 (url "https://github.com/savoirfairelinux/cqfd")
926 (commit (string-append "v" version))))
927 (file-name (git-file-name name version))
928 (sha256
929 (base32
930 "1p0093hx2ryxng2l53cqaca8g7gw888ydq2i328raip62pcdrccp"))))
931 (build-system gnu-build-system)
932 (arguments
933 ;; The test suite requires a docker daemon and connectivity.
934 (list
935 #:tests? #f
936 #:make-flags #~(list (string-append "COMPLETIONSDIR="
937 #$output "/etc/bash_completion.d")
938 (string-append "PREFIX=" #$output))
939 #:phases #~(modify-phases %standard-phases
940 (delete 'configure)
941 (delete 'build))))
942 (home-page "https://github.com/savoirfairelinux/cqfd")
943 (synopsis "Convenience wrapper for Docker")
944 (description "cqfd is a Bash script that provides a quick and convenient
945way to run commands in the current directory, but within a Docker container
946defined in a per-project configuration file.")
947 (license license:gpl3+)))
948
949(define-public tini
950 (package
951 (name "tini")
952 (version "0.19.0")
953 (source (origin
954 (method git-fetch)
955 (uri (git-reference
956 (url "https://github.com/krallin/tini")
957 (commit (string-append "v" version))))
958 (file-name (git-file-name name version))
959 (sha256
960 (base32
961 "1hnnvjydg7gi5gx6nibjjdnfipblh84qcpajc08nvr44rkzswck4"))))
962 (build-system cmake-build-system)
963 (arguments
964 `(#:tests? #f ;tests require a Docker daemon
965 ;; 'tini-static' is a static binary, which leads CMake to fail with
966 ;; ‘file RPATH_CHANGE could not write new RPATH: ...’. Clear
967 ;; CMAKE_INSTALL_RPATH to avoid that problem.
968 #:configure-flags '("-DCMAKE_INSTALL_RPATH=")))
969 (home-page "https://github.com/krallin/tini")
970 (synopsis "Tiny but valid init for containers")
971 (description "Tini is an init program specifically designed for use with
972containers. It manages a single child process and ensures that any zombie
973processes produced from it are reaped and that signals are properly forwarded.
974Tini is integrated with Docker.")
975 (license license:expat)))
976
977(define-public docker-registry
978 (package
979 (name "docker-registry")
980 ;; XXX: The project ships a "vendor" directory containing all
981 ;; dependencies, consider to review and package them. The Golang library
982 ;; is packaged in (gnu packges golang-xyz) as
983 ;; go-github-com-docker-distribution.
984 (version "2.8.3")
985 (source (origin
986 (method git-fetch)
987 (uri (git-reference
988 (url "https://github.com/docker/distribution")
989 (commit (string-append "v" version))))
990 (file-name (git-file-name name version))
991 (sha256
992 (base32
993 "0dbaxmkhg53anhkzngyzlxm2bd4dwv0sv75zip1rkm0874wjbxzb"))))
994 (build-system go-build-system)
995 (arguments
996 (list
997 #:import-path "github.com/docker/distribution"
998 #:test-subdirs #~(list "configuration"
999 "context"
1000 "health"
1001 "manifest"
1002 "notifications/..."
1003 "uuid")
1004 #:phases
1005 #~(modify-phases %standard-phases
1006 (add-after 'unpack 'chdir-to-src
1007 (lambda _ (chdir "src/github.com/docker/distribution")))
1008 (add-after 'chdir-to-src 'fix-versioning
1009 (lambda _
1010 ;; The Makefile use git to compute the version and the
1011 ;; revision. This requires the .git directory that we don't have
1012 ;; anymore in the unpacked source.
1013 (substitute* "Makefile"
1014 (("^VERSION=\\$\\(.*\\)")
1015 (string-append "VERSION=v" #$version))
1016 ;; The revision originally used the git hash with .m appended
1017 ;; if there was any local modifications.
1018 (("^REVISION=\\$\\(.*\\)") "REVISION=0"))))
1019 (replace 'build
1020 (lambda _
1021 (invoke "make" "binaries")))
1022 (replace 'install
1023 (lambda _
1024 (let ((bin (string-append #$output "/bin")))
1025 (mkdir-p bin)
1026 (for-each
1027 (lambda (file)
1028 (install-file (string-append "bin/" file) bin))
1029 '("digest"
1030 "registry"
1031 "registry-api-descriptor-template")))
1032 (let ((doc (string-append
1033 #$output "/share/doc/" #$name "-" #$version)))
1034 (mkdir-p doc)
1035 (for-each
1036 (lambda (file)
1037 (install-file file doc))
1038 '("BUILDING.md"
1039 "CONTRIBUTING.md"
1040 "LICENSE"
1041 "MAINTAINERS"
1042 "README.md"
1043 "ROADMAP.md"))
1044 (copy-recursively "docs/" (string-append doc "/docs")))
1045 (let ((examples
1046 (string-append
1047 #$output "/share/doc/" #$name "-" #$version
1048 "/registry-example-configs")))
1049 (mkdir-p examples)
1050 (for-each
1051 (lambda (file)
1052 (install-file (string-append "cmd/registry/" file) examples))
1053 '("config-cache.yml"
1054 "config-example.yml"
1055 "config-dev.yml")))))
1056 (delete 'install-license-files))))
1057 (home-page "https://github.com/docker/distribution")
1058 (synopsis "Docker registry server and associated tools")
1059 (description "The Docker registry server enable you to host your own
1060docker registry. With it, there is also two other utilities:
1061@itemize
1062@item The digest utility is a tool that generates checksums compatibles with
1063various docker manifest files.
1064@item The registry-api-descriptor-template is a tool for generating API
1065specifications from the docs/spec/api.md.tmpl file.
1066@end itemize")
1067 (license license:asl2.0)))