projects/guix·blob bootstrap-team · refs

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