projects/guix·blob sysadmin-team · refs

1091 lines · 46.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 python-udocker
422 (package
423 (name "python-udocker")
424 (version "1.3.17")
425 (source
426 (origin
427 (method git-fetch)
428 (uri (git-reference
429 (url "https://github.com/indigo-dc/udocker")
430 (commit version)))
431 (file-name (git-file-name name version))
432 (sha256
433 (base32 "1nbsj3kwlnkr12ykl1xd0r2hykikhrs0z9wgfb26y2nxpf85z3rz"))))
434 (build-system pyproject-build-system)
435 ;; Daemon chroot inconsistencies.
436 (arguments (list #:test-flags #~(list "-k" "not test_05__get_volume_bindings")))
437 (native-inputs (list python-pytest python-setuptools))
438 (home-page "https://github.com/indigo-dc/udocker")
439 (synopsis "Execute simple docker containers without root privileges")
440 (description
441 "This package provides a basic user tool to execute simple docker containers in
442batch or interactive systems without root privileges.")
443 (license license:asl2.0)))
444
445(define-public containerd
446 (package
447 (name "containerd")
448 (version "1.6.22")
449 (source
450 (origin
451 (method git-fetch)
452 (uri (git-reference
453 (url "https://github.com/containerd/containerd")
454 (commit (string-append "v" version))))
455 (file-name (git-file-name name version))
456 (sha256
457 (base32 "1m31y00sq2m76m1jiq4znws8gxbgkh5adklvqibxiz1b96vvwjk8"))
458 (patches
459 (search-patches "containerd-create-pid-file.patch"
460 "containerd-fix-includes.patch"))))
461 (build-system go-build-system)
462 (arguments
463 (let ((make-flags #~(list (string-append "VERSION=" #$version)
464 (string-append "DESTDIR=" #$output)
465 "PREFIX="
466 "REVISION=0")))
467 (list
468 #:import-path "github.com/containerd/containerd"
469 ;; XXX: This package contains full vendor, tests fail when run with
470 ;; "...", limit to the project's root. Try to unvendor.
471 #:test-subdirs #~(list ".")
472 #:phases
473 #~(modify-phases %standard-phases
474 (add-after 'unpack 'patch-paths
475 (lambda* (#:key inputs import-path outputs #:allow-other-keys)
476 (with-directory-excursion (string-append "src/" import-path)
477 (substitute* "runtime/v1/linux/runtime.go"
478 (("defaultRuntime[ \t]*=.*")
479 (string-append "defaultRuntime = \""
480 (search-input-file inputs "/sbin/runc")
481 "\"\n"))
482 (("defaultShim[ \t]*=.*")
483 (string-append "defaultShim = \""
484 (assoc-ref outputs "out")
485 "/bin/containerd-shim\"\n")))
486 (substitute* "pkg/cri/config/config_unix.go"
487 (("DefaultRuntimeName: \"runc\"")
488 (string-append "DefaultRuntimeName: \""
489 (search-input-file inputs "/sbin/runc")
490 "\""))
491 ;; ContainerdConfig.Runtimes
492 (("\"runc\":")
493 (string-append "\""
494 (search-input-file inputs "/sbin/runc")
495 "\":")))
496 (substitute* "vendor/github.com/containerd/go-runc/runc.go"
497 (("DefaultCommand[ \t]*=.*")
498 (string-append "DefaultCommand = \""
499 (search-input-file inputs "/sbin/runc")
500 "\"\n")))
501 (substitute* "vendor/github.com/containerd/continuity/testutil\
502/loopback/loopback_linux.go"
503 (("exec\\.Command\\(\"losetup\"")
504 (string-append "exec.Command(\""
505 (search-input-file inputs "/sbin/losetup")
506 "\"")))
507 (substitute* "archive/compression/compression.go"
508 (("exec\\.LookPath\\(\"unpigz\"\\)")
509 (string-append "\""
510 (search-input-file inputs "/bin/unpigz")
511 "\", error(nil)"))))))
512 (replace 'build
513 (lambda* (#:key import-path #:allow-other-keys)
514 (with-directory-excursion (string-append "src/" import-path)
515 (apply invoke "make" #$make-flags))))
516 (replace 'install
517 (lambda* (#:key import-path #:allow-other-keys)
518 (with-directory-excursion (string-append "src/" import-path)
519 (apply invoke "make" "install" #$make-flags))))))))
520 (inputs
521 (list btrfs-progs libseccomp pigz runc util-linux))
522 (native-inputs
523 (list go pkg-config))
524 (synopsis "Docker container runtime")
525 (description "This package provides the container daemon for Docker.
526It includes image transfer and storage, container execution and supervision,
527network attachments.")
528 (home-page "https://containerd.io/")
529 (license license:asl2.0)))
530
531;;; Private package that shouldn't be used directly; its purposes is to be
532;;; used as a template for the various packages it contains. It doesn't build
533;;; anyway, as it needs many dependencies that aren't being satisfied.
534(define docker-libnetwork
535 ;; There are no recent release for libnetwork, so choose the last commit of
536 ;; the branch that Docker uses, as can be seen in the 'vendor.conf' Docker
537 ;; source file. NOTE - It is important that this version is kept in sync
538 ;; with the version of Docker being used.
539 (let ((commit "3797618f9a38372e8107d8c06f6ae199e1133ae8")
540 (version (version-major+minor %docker-version))
541 (revision "3"))
542 (package
543 (name "docker-libnetwork")
544 (version (git-version version revision commit))
545 (source (origin
546 (method git-fetch)
547 (uri (git-reference
548 ;; Redirected from github.com/docker/libnetwork.
549 (url "https://github.com/moby/libnetwork")
550 (commit commit)))
551 (file-name (git-file-name name version))
552 (sha256
553 (base32
554 "1km3p6ya9az0ax2zww8wb5vbifr1gj5n9l82i273m9f3z9f2mq2p"))
555 ;; Delete bundled ("vendored") free software source code.
556 (modules '((guix build utils)))
557 (snippet '(delete-file-recursively "vendor"))))
558 (build-system go-build-system)
559 (arguments
560 `(#:import-path "github.com/moby/libnetwork/"))
561 (home-page "https://github.com/moby/libnetwork/")
562 (synopsis "Networking for containers")
563 (description "Libnetwork provides a native Go implementation for
564connecting containers. The goal of @code{libnetwork} is to deliver a robust
565container network model that provides a consistent programming interface and
566the required network abstractions for applications.")
567 (license license:asl2.0))))
568
569(define-public docker-libnetwork-cmd-proxy
570 (package
571 (inherit docker-libnetwork)
572 (name "docker-libnetwork-cmd-proxy")
573 (arguments
574 (list
575 ;; The tests are unsupported on all architectures except x86_64-linux.
576 #:tests? (and (not (%current-target-system)) (target-x86-64?))
577 #:install-source? #f
578 #:import-path "github.com/docker/libnetwork/cmd/proxy"
579 #:unpack-path "github.com/docker/libnetwork"))
580 (native-inputs
581 (list go-github-com-sirupsen-logrus ; for tests.
582 go-github-com-vishvananda-netlink
583 go-github-com-vishvananda-netns
584 go-golang-org-x-crypto
585 go-golang-org-x-sys
586 go-sctp))
587 (synopsis "Docker user-space proxy")
588 (description
589 "This package provides a proxy running in the user space. It is used by
590the built-in registry server of Docker.")
591 (license license:asl2.0)))
592
593;; TODO: Patch out modprobes for ip_vs, nf_conntrack,
594;; brige, nf_conntrack_netlink, aufs.
595(define-public docker
596 (package
597 (name "docker")
598 (version %docker-version)
599 (source
600 (origin
601 (method git-fetch)
602 (uri (git-reference
603 (url "https://github.com/moby/moby")
604 (commit (string-append "v" version))))
605 (file-name (git-file-name name version))
606 (sha256
607 (base32 "017frilx35w3m4dz3n6m2f293q4fq4jrk6hl8f7wg5xs3r8hswvq"))))
608 (build-system gnu-build-system)
609 (arguments
610 (list
611 #:modules
612 '((guix build gnu-build-system)
613 ((guix build go-build-system) #:prefix go:)
614 (guix build union)
615 (guix build utils))
616 #:imported-modules
617 `(,@%default-gnu-imported-modules
618 (guix build union)
619 (guix build go-build-system))
620 #:phases
621 #~(modify-phases %standard-phases
622 (add-after 'unpack 'patch-paths
623 (lambda* (#:key inputs #:allow-other-keys)
624 (substitute* "builder/builder-next/executor_unix.go"
625 (("CommandCandidates:.*runc.*")
626 (string-append "CommandCandidates: []string{\""
627 (search-input-file inputs "/sbin/runc")
628 "\"},\n")))
629 (substitute* "vendor/github.com/containerd/go-runc/runc.go"
630 (("DefaultCommand = .*")
631 (string-append "DefaultCommand = \""
632 (search-input-file inputs "/sbin/runc")
633 "\"\n")))
634 (substitute* "vendor/github.com/containerd/containerd/\
635runtime/v1/linux/runtime.go"
636 (("defaultRuntime[ \t]*=.*")
637 (string-append "defaultRuntime = \""
638 (search-input-file inputs "/sbin/runc")
639 "\"\n"))
640 (("defaultShim[ \t]*=.*")
641 (string-append "defaultShim = \""
642 (search-input-file inputs "/bin/containerd-shim")
643 "\"\n")))
644 (substitute* "daemon/daemon_unix.go"
645 (("DefaultShimBinary = .*")
646 (string-append "DefaultShimBinary = \""
647 (search-input-file inputs "/bin/containerd-shim")
648 "\"\n"))
649 (("DefaultRuntimeBinary = .*")
650 (string-append "DefaultRuntimeBinary = \""
651 (search-input-file inputs "/sbin/runc")
652 "\"\n")))
653 (substitute* "daemon/runtime_unix.go"
654 (("defaultRuntimeName = .*")
655 (string-append "defaultRuntimeName = \""
656 (search-input-file inputs "/sbin/runc")
657 "\"\n")))
658 (substitute* "daemon/config/config.go"
659 (("StockRuntimeName = .*")
660 (string-append "StockRuntimeName = \""
661 (search-input-file inputs "/sbin/runc")
662 "\"\n"))
663 (("DefaultInitBinary = .*")
664 (string-append "DefaultInitBinary = \""
665 (search-input-file inputs "/bin/tini-static")
666 "\"\n")))
667 (substitute* "daemon/config/config_common_unix_test.go"
668 (("expectedInitPath: \"docker-init\"")
669 (string-append "expectedInitPath: \""
670 (search-input-file inputs "/bin/tini-static")
671 "\"")))
672 (substitute* "vendor/github.com/moby/buildkit/executor/\
673runcexecutor/executor.go"
674 (("var defaultCommandCandidates = .*")
675 (string-append "var defaultCommandCandidates = []string{\""
676 (search-input-file inputs "/sbin/runc") "\"}")))
677 (substitute* "vendor/github.com/docker/libnetwork/portmapper/proxy.go"
678 (("var userlandProxyCommandName = .*")
679 (string-append "var userlandProxyCommandName = \""
680 (search-input-file inputs "/bin/proxy")
681 "\"\n")))
682 (substitute* "pkg/archive/archive.go"
683 (("string\\{\"xz")
684 (string-append "string{\"" (search-input-file inputs "/bin/xz"))))
685
686 (let ((source-files (filter (lambda (name)
687 (not (string-contains name "test")))
688 (find-files "." "\\.go$"))))
689 (let-syntax ((substitute-LookPath*
690 (syntax-rules ()
691 ((_ (source-text path) ...)
692 (substitute* source-files
693 (((string-append "\\<exec\\.LookPath\\(\""
694 source-text
695 "\")"))
696 (string-append "\""
697 (search-input-file inputs path)
698 "\", error(nil)")) ...))))
699 (substitute-Command*
700 (syntax-rules ()
701 ((_ (source-text path) ...)
702 (substitute* source-files
703 (((string-append "\\<(re)?exec\\.Command\\(\""
704 source-text
705 "\"") _ re?)
706 (string-append (if re? re? "")
707 "exec.Command(\""
708 (search-input-file inputs path)
709 "\"")) ...)))))
710 (substitute-LookPath*
711 ("containerd" "/bin/containerd")
712 ("ps" "/bin/ps")
713 ("mkfs.xfs" "/sbin/mkfs.xfs")
714 ("lvmdiskscan" "/sbin/lvmdiskscan")
715 ("pvdisplay" "/sbin/pvdisplay")
716 ("blkid" "/sbin/blkid")
717 ("unpigz" "/bin/unpigz")
718 ("iptables" "/sbin/iptables")
719 ("ip6tables" "/sbin/ip6tables")
720 ("iptables-legacy" "/sbin/iptables")
721 ("ip" "/sbin/ip"))
722
723 (substitute-Command*
724 ("modprobe" "/bin/modprobe")
725 ("pvcreate" "/sbin/pvcreate")
726 ("vgcreate" "/sbin/vgcreate")
727 ("lvcreate" "/sbin/lvcreate")
728 ("lvconvert" "/sbin/lvconvert")
729 ("lvchange" "/sbin/lvchange")
730 ("mkfs.xfs" "/sbin/mkfs.xfs")
731 ("xfs_growfs" "/sbin/xfs_growfs")
732 ("mkfs.ext4" "/sbin/mkfs.ext4")
733 ("tune2fs" "/sbin/tune2fs")
734 ("blkid" "/sbin/blkid")
735 ("resize2fs" "/sbin/resize2fs")
736 ("ps" "/bin/ps")
737 ("losetup" "/sbin/losetup")
738 ("uname" "/bin/uname")
739 ("dbus-launch" "/bin/dbus-launch")
740 ("git" "/bin/git")))
741 ;; docker-mountfrom ??
742 ;; docker
743 ;; docker-untar ??
744 ;; docker-applyLayer ??
745 ;; /usr/bin/uname
746 ;; grep
747 ;; apparmor_parser
748
749 ;; Make compilation fail when, in future versions, Docker
750 ;; invokes other programs we don't know about and thus don't
751 ;; substitute.
752 (substitute* source-files
753 ;; Search for Java in PATH.
754 (("\\<exec\\.Command\\(\"java\"")
755 "xxec.Command(\"java\"")
756 ;; Search for AUFS in PATH (mainline Linux doesn't support it).
757 (("\\<exec\\.Command\\(\"auplink\"")
758 "xxec.Command(\"auplink\"")
759 ;; Fail on other unsubstituted commands.
760 (("\\<exec\\.Command\\(\"([a-zA-Z0-9][a-zA-Z0-9_-]*)\""
761 _ executable)
762 (string-append "exec.Guix_doesnt_want_Command(\""
763 executable "\""))
764 (("\\<xxec\\.Command")
765 "exec.Command")
766 ;; Search for ZFS in PATH.
767 (("\\<LookPath\\(\"zfs\"\\)") "LooxPath(\"zfs\")")
768 ;; Do not fail when buildkit-qemu-<target> isn't found.
769 ;; FIXME: We might need to package buildkit and docker's
770 ;; buildx plugin, to support qemu-based docker containers.
771 (("\\<LookPath\\(\"buildkit-qemu-\"") "LooxPath(\"buildkit-qemu-\"")
772 ;; Fail on other unsubstituted LookPaths.
773 (("\\<LookPath\\(\"") "Guix_doesnt_want_LookPath\\(\"")
774 (("\\<LooxPath") "LookPath")))))
775 (add-after 'patch-paths 'delete-failing-tests
776 (lambda _
777 ;; Needs internet access.
778 (delete-file "builder/remotecontext/git/gitutils_test.go")
779 ;; Permission denied.
780 (delete-file "daemon/graphdriver/devmapper/devmapper_test.go")
781 ;; Operation not permitted (idtools.MkdirAllAndChown).
782 (delete-file "daemon/graphdriver/vfs/vfs_test.go")
783 ;; Timeouts after 5 min.
784 (delete-file "plugin/manager_linux_test.go")
785 ;; Operation not permitted.
786 (delete-file "daemon/graphdriver/aufs/aufs_test.go")
787 (delete-file "daemon/graphdriver/btrfs/btrfs_test.go")
788 (delete-file "daemon/graphdriver/overlay/overlay_test.go")
789 (delete-file "daemon/graphdriver/overlay2/overlay_test.go")
790 (delete-file "pkg/chrootarchive/archive_unix_test.go")
791 (delete-file "daemon/container_unix_test.go")
792 ;; This file uses cgroups and /proc.
793 (delete-file "pkg/sysinfo/sysinfo_linux_test.go")
794 ;; This file uses cgroups.
795 (delete-file "runconfig/config_test.go")
796 ;; This file uses /var.
797 (delete-file "daemon/oci_linux_test.go")
798 ;; Signal tests fail in bizarre ways
799 (delete-file "pkg/signal/signal_linux_test.go")))
800 (replace 'configure
801 (lambda _
802 (setenv "DOCKER_BUILDTAGS" "seccomp")
803 (setenv "DOCKER_GITCOMMIT" (string-append "v" #$%docker-version))
804 (setenv "VERSION" (string-append #$%docker-version "-ce"))
805 ;; Automatically use bundled dependencies.
806 ;; TODO: Unbundle - see file "vendor.conf".
807 (setenv "AUTO_GOPATH" "1")
808 ;; Respectively, strip the symbol table and debug
809 ;; information, and the DWARF symbol table.
810 (setenv "LDFLAGS" "-s -w")
811 ;; Make build faster
812 (setenv "GOCACHE" "/tmp")))
813 (add-before 'build 'setup-go-environment
814 (assoc-ref go:%standard-phases 'setup-go-environment))
815 (replace 'build
816 (lambda _
817 ;; Our LD doesn't like the statically linked relocatable things
818 ;; that go produces, so install the dynamic version of
819 ;; dockerd instead.
820 (setenv "BUILDFLAGS" "-trimpath")
821 (invoke "hack/make.sh" "dynbinary")))
822 (replace 'check
823 (lambda* (#:key tests? #:allow-other-keys)
824 (when tests?
825 ;; The build process generated a file because the environment
826 ;; variable "AUTO_GOPATH" was set. Use it.
827 (setenv "GOPATH" (string-append (getcwd) "/.gopath"))
828 ;; ".gopath/src/github.com/docker/docker" is a link to the current
829 ;; directory and chdir would canonicalize to that.
830 ;; But go needs to have the uncanonicalized directory name, so
831 ;; store that.
832 (setenv "PWD" (string-append
833 (getcwd) "/.gopath/src/github.com/docker/docker"))
834 (with-directory-excursion ".gopath/src/github.com/docker/docker"
835 (invoke "hack/test/unit"))
836 (setenv "PWD" #f))))
837 (replace 'install
838 (lambda* (#:key outputs #:allow-other-keys)
839 (let* ((out (assoc-ref outputs "out"))
840 (out-bin (string-append out "/bin")))
841 (install-file "bundles/dynbinary-daemon/dockerd" out-bin)
842 (install-file (string-append "bundles/dynbinary-daemon/dockerd-"
843 (getenv "VERSION"))
844 out-bin)))))))
845 (inputs
846 (list btrfs-progs
847 containerd ; for containerd-shim
848 coreutils
849 dbus
850 docker-libnetwork-cmd-proxy
851 e2fsprogs
852 git
853 iproute
854 iptables
855 kmod
856 libseccomp
857 pigz
858 procps
859 runc
860 util-linux
861 lvm2
862 tini
863 xfsprogs-5.9
864 xz))
865 (native-inputs
866 (list eudev ; TODO: Should be propagated by lvm2 (.pc -> .pc)
867 go-1.22 gotestsum pkg-config))
868 (synopsis "Container component library and daemon")
869 (description "This package provides a framework to assemble specialized
870container systems. It includes components for orchestration, image
871management, secret management, configuration management, networking,
872provisioning etc.")
873 (home-page "https://mobyproject.org/")
874 (license license:asl2.0)))
875
876(define-public docker-cli
877 (package
878 (name "docker-cli")
879 (version %docker-version)
880 (source
881 (origin
882 (method git-fetch)
883 (uri (git-reference
884 (url "https://github.com/docker/cli")
885 (commit (string-append "v" version))))
886 (file-name (git-file-name name version))
887 (sha256
888 (base32 "0szwaxiasy77mm90wj2qg747zb9lyiqndg5halg7qbi41ng6ry0h"))))
889 (build-system go-build-system)
890 (arguments
891 `(#:import-path "github.com/docker/cli"
892 ;; TODO: Tests require a running Docker daemon.
893 #:tests? #f
894 #:phases
895 (modify-phases %standard-phases
896 (add-before 'build 'setup-environment-2
897 (lambda _
898 ;; Respectively, strip the symbol table and debug
899 ;; information, and the DWARF symbol table.
900 (setenv "LDFLAGS" "-s -w")
901
902 ;; Make sure "docker -v" prints a usable version string.
903 (setenv "VERSION" ,%docker-version)
904
905 ;; Make build reproducible.
906 (setenv "BUILDTIME" "1970-01-01 00:00:01.000000000+00:00")
907 (symlink "src/github.com/docker/cli/scripts" "./scripts")
908 (symlink "src/github.com/docker/cli/docker.Makefile" "./docker.Makefile")))
909 (replace 'build
910 (lambda _
911 (setenv "GO_LINKMODE" "dynamic")
912 (invoke "./scripts/build/binary")))
913 (replace 'check
914 (lambda* (#:key make-flags tests? #:allow-other-keys)
915 (setenv "PATH" (string-append (getcwd) "/build:" (getenv "PATH")))
916 (when tests?
917 ;; Use the newly-built docker client for the tests.
918 (with-directory-excursion "src/github.com/docker/cli"
919 ;; TODO: Run test-e2e as well?
920 (apply invoke "make" "-f" "docker.Makefile" "test-unit"
921 (or make-flags '()))))))
922 (replace 'install
923 (lambda* (#:key outputs #:allow-other-keys)
924 (let* ((out (assoc-ref outputs "out"))
925 (out-bin (string-append out "/bin"))
926 (etc (string-append out "/etc")))
927 (with-directory-excursion "src/github.com/docker/cli/contrib/completion"
928 (install-file "bash/docker"
929 (string-append etc "/bash_completion.d"))
930 (install-file "fish/docker.fish"
931 (string-append etc "/fish/completions"))
932 (install-file "zsh/_docker"
933 (string-append etc "/zsh/site-functions")))
934 (install-file "build/docker" out-bin)))))))
935 (native-inputs
936 (list go libltdl pkg-config))
937 (synopsis "Command line interface to Docker")
938 (description "This package provides a command line interface to Docker.")
939 (home-page "https://www.docker.com/")
940 (license license:asl2.0)))
941
942(define-public cqfd
943 (package
944 (name "cqfd")
945 (version "5.6.0")
946 (source (origin
947 (method git-fetch)
948 (uri (git-reference
949 (url "https://github.com/savoirfairelinux/cqfd")
950 (commit (string-append "v" version))))
951 (file-name (git-file-name name version))
952 (sha256
953 (base32
954 "1p0093hx2ryxng2l53cqaca8g7gw888ydq2i328raip62pcdrccp"))))
955 (build-system gnu-build-system)
956 (arguments
957 ;; The test suite requires a docker daemon and connectivity.
958 (list
959 #:tests? #f
960 #:make-flags #~(list (string-append "COMPLETIONSDIR="
961 #$output "/etc/bash_completion.d")
962 (string-append "PREFIX=" #$output))
963 #:phases #~(modify-phases %standard-phases
964 (delete 'configure)
965 (delete 'build))))
966 (home-page "https://github.com/savoirfairelinux/cqfd")
967 (synopsis "Convenience wrapper for Docker")
968 (description "cqfd is a Bash script that provides a quick and convenient
969way to run commands in the current directory, but within a Docker container
970defined in a per-project configuration file.")
971 (license license:gpl3+)))
972
973(define-public tini
974 (package
975 (name "tini")
976 (version "0.19.0")
977 (source (origin
978 (method git-fetch)
979 (uri (git-reference
980 (url "https://github.com/krallin/tini")
981 (commit (string-append "v" version))))
982 (file-name (git-file-name name version))
983 (sha256
984 (base32
985 "1hnnvjydg7gi5gx6nibjjdnfipblh84qcpajc08nvr44rkzswck4"))))
986 (build-system cmake-build-system)
987 (arguments
988 `(#:tests? #f ;tests require a Docker daemon
989 ;; 'tini-static' is a static binary, which leads CMake to fail with
990 ;; ‘file RPATH_CHANGE could not write new RPATH: ...’. Clear
991 ;; CMAKE_INSTALL_RPATH to avoid that problem.
992 #:configure-flags '("-DCMAKE_INSTALL_RPATH=")))
993 (home-page "https://github.com/krallin/tini")
994 (synopsis "Tiny but valid init for containers")
995 (description "Tini is an init program specifically designed for use with
996containers. It manages a single child process and ensures that any zombie
997processes produced from it are reaped and that signals are properly forwarded.
998Tini is integrated with Docker.")
999 (license license:expat)))
1000
1001(define-public docker-registry
1002 (package
1003 (name "docker-registry")
1004 ;; XXX: The project ships a "vendor" directory containing all
1005 ;; dependencies, consider to review and package them. The Golang library
1006 ;; is packaged in (gnu packges golang-xyz) as
1007 ;; go-github-com-docker-distribution.
1008 (version "2.8.3")
1009 (source (origin
1010 (method git-fetch)
1011 (uri (git-reference
1012 (url "https://github.com/docker/distribution")
1013 (commit (string-append "v" version))))
1014 (file-name (git-file-name name version))
1015 (sha256
1016 (base32
1017 "0dbaxmkhg53anhkzngyzlxm2bd4dwv0sv75zip1rkm0874wjbxzb"))))
1018 (build-system go-build-system)
1019 (arguments
1020 (list
1021 #:import-path "github.com/docker/distribution"
1022 #:test-subdirs #~(list "configuration"
1023 "context"
1024 "health"
1025 "manifest"
1026 "notifications/..."
1027 "uuid")
1028 #:phases
1029 #~(modify-phases %standard-phases
1030 (add-after 'unpack 'chdir-to-src
1031 (lambda _ (chdir "src/github.com/docker/distribution")))
1032 (add-after 'chdir-to-src 'fix-versioning
1033 (lambda _
1034 ;; The Makefile use git to compute the version and the
1035 ;; revision. This requires the .git directory that we don't have
1036 ;; anymore in the unpacked source.
1037 (substitute* "Makefile"
1038 (("^VERSION=\\$\\(.*\\)")
1039 (string-append "VERSION=v" #$version))
1040 ;; The revision originally used the git hash with .m appended
1041 ;; if there was any local modifications.
1042 (("^REVISION=\\$\\(.*\\)") "REVISION=0"))))
1043 (replace 'build
1044 (lambda _
1045 (invoke "make" "binaries")))
1046 (replace 'install
1047 (lambda _
1048 (let ((bin (string-append #$output "/bin")))
1049 (mkdir-p bin)
1050 (for-each
1051 (lambda (file)
1052 (install-file (string-append "bin/" file) bin))
1053 '("digest"
1054 "registry"
1055 "registry-api-descriptor-template")))
1056 (let ((doc (string-append
1057 #$output "/share/doc/" #$name "-" #$version)))
1058 (mkdir-p doc)
1059 (for-each
1060 (lambda (file)
1061 (install-file file doc))
1062 '("BUILDING.md"
1063 "CONTRIBUTING.md"
1064 "LICENSE"
1065 "MAINTAINERS"
1066 "README.md"
1067 "ROADMAP.md"))
1068 (copy-recursively "docs/" (string-append doc "/docs")))
1069 (let ((examples
1070 (string-append
1071 #$output "/share/doc/" #$name "-" #$version
1072 "/registry-example-configs")))
1073 (mkdir-p examples)
1074 (for-each
1075 (lambda (file)
1076 (install-file (string-append "cmd/registry/" file) examples))
1077 '("config-cache.yml"
1078 "config-example.yml"
1079 "config-dev.yml")))))
1080 (delete 'install-license-files))))
1081 (home-page "https://github.com/docker/distribution")
1082 (synopsis "Docker registry server and associated tools")
1083 (description "The Docker registry server enable you to host your own
1084docker registry. With it, there is also two other utilities:
1085@itemize
1086@item The digest utility is a tool that generates checksums compatibles with
1087various docker manifest files.
1088@item The registry-api-descriptor-template is a tool for generating API
1089specifications from the docs/spec/api.md.tmpl file.
1090@end itemize")
1091 (license license:asl2.0)))