1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2021 Timmy Douglas <mail@timmydouglas.com>
3 ;;; Copyright © 2022 Tobias Geerinckx-Rice <me@tobias.gr>
4 ;;; Copyright © 2022 Zhu Zihao <all_but_last@163.com>
6 ;;; This file is part of GNU Guix.
8 ;;; GNU Guix is free software; you can redistribute it and/or modify it
9 ;;; under the terms of the GNU General Public License as published by
10 ;;; the Free Software Foundation; either version 3 of the License, or (at
11 ;;; your option) any later version.
13 ;;; GNU Guix is distributed in the hope that it will be useful, but
14 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;;; GNU General Public License for more details.
18 ;;; You should have received a copy of the GNU General Public License
19 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
21 (define-module (gnu packages containers)
22 #:use-module (guix gexp)
23 #:use-module ((guix licenses) #:prefix license:)
24 #:use-module (gnu packages)
25 #:use-module (guix packages)
26 #:use-module (guix download)
27 #:use-module (guix git-download)
28 #:use-module (guix build-system gnu)
29 #:use-module (guix build-system go)
30 #:use-module (guix build-system meson)
31 #:use-module (guix utils)
32 #:use-module (gnu packages admin)
33 #:use-module (gnu packages autotools)
34 #:use-module (gnu packages base)
35 #:use-module (gnu packages bash)
36 #:use-module (gnu packages check)
37 #:use-module (gnu packages compression)
38 #:use-module (gnu packages glib)
39 #:use-module (gnu packages gnupg)
40 #:use-module (gnu packages golang)
41 #:use-module (gnu packages linux)
42 #:use-module (gnu packages python)
43 #:use-module (gnu packages networking)
44 #:use-module (gnu packages pkg-config)
45 #:use-module (gnu packages selinux)
46 #:use-module (gnu packages version-control)
47 #:use-module (gnu packages virtualization)
48 #:use-module (gnu packages web))
51 (let ((commit "c381048530aa750495cf502ddb7181f2ded5b400"))
59 (url "https://github.com/containers/crun")
63 (base32 "0x2xmr5sv9ivvcv5fl5jjk4kq9b3n97s5hsqiqfwl4rz8qcz4xk1"))
64 (file-name (git-file-name name version))))
65 (build-system gnu-build-system)
67 `(#:configure-flags '("--disable-systemd")
68 #:tests? #f ; XXX: needs /sys/fs/cgroup mounted
70 (modify-phases %standard-phases
71 (add-after 'unpack 'do-not-depend-on-git
73 (substitute* "autogen.sh"
74 (("^git submodule update.*")
76 (with-output-to-file "git-version.h"
78 (display (string-append
79 "/* autogenerated. */\n#ifndef GIT_VERSION\n# define GIT_VERSION \""
82 (add-after 'unpack 'fix-tests
84 (substitute* (find-files "tests" "\\.(c|py)")
85 (("/bin/true") (which "true"))
86 (("/bin/false") (which "false"))
87 ; relies on sd_notify which requires systemd?
88 (("\"sd-notify\" : test_sd_notify,") "")
89 (("\"sd-notify-file\" : test_sd_notify_file,") "")))))))
101 (home-page "https://github.com/containers/crun")
102 (synopsis "Open Container Initiative (OCI) Container runtime")
104 "crun is a fast and low-memory footprint Open Container Initiative (OCI)
105 Container Runtime fully written in C.")
106 (license license:gpl2+))))
108 (define-public conmon
116 (url "https://github.com/containers/conmon")
117 (commit (string-append "v" version))))
119 (base32 "1cxklcihb2i4ywli0fxafkp2gi1x831r37z7spnigaj6pzj1517w"))
120 (file-name (git-file-name name version))))
121 (build-system gnu-build-system)
124 #~(list (string-append "CC=" #$(cc-for-target))
125 (string-append "PREFIX=" #$output))
126 ;; XXX: uses `go get` to download 50 packages, runs a ginkgo test suite
127 ;; then tries to download busybox and use a systemd logging library
128 ;; see also https://github.com/containers/conmon/blob/main/nix/derivation.nix
132 #~(modify-phases %standard-phases
134 (add-after 'unpack 'set-env
136 ;; when running go, things fail because
137 ;; HOME=/homeless-shelter.
138 (setenv "HOME" "/tmp"))))))
147 (home-page "https://github.com/containers/conmon")
148 (synopsis "Monitoring tool for Open Container Initiative (OCI) runtime")
150 "Conmon is a monitoring program and communication tool between a container
151 manager (like Podman or CRI-O) and an Open Container Initiative (OCI)
152 runtime (like runc or crun) for a single container.")
153 (license license:asl2.0)))
155 (define-public libslirp
163 (url "https://gitlab.freedesktop.org/slirp/libslirp")
164 (commit (string-append "v" version))))
166 (base32 "0dny8187a8qh6akaa37aa9b5pjxx88f02wh6achp4mygff0ipxba"))
167 (file-name (git-file-name name version))))
168 (build-system meson-build-system)
170 ;; In Requires of slirp.pc.
174 (home-page "https://gitlab.freedesktop.org/slirp/libslirp")
175 (synopsis "User-mode networking library")
177 "libslirp is a user-mode networking library used by virtual machines,
178 containers or various tools.")
179 (license license:bsd-3)))
181 (define-public slirp4netns
189 (url "https://github.com/rootless-containers/slirp4netns")
190 (commit (string-append "v" version))))
192 (base32 "03llv4dlf7qqxwz4zdyk926g4bigfj2gb50glm70ciflpvzs8081"))
193 (file-name (git-file-name name version))))
194 (build-system gnu-build-system)
196 '(#:tests? #f ; XXX: open("/dev/net/tun"): No such file or directory
197 #:phases (modify-phases %standard-phases
198 (add-after 'unpack 'fix-hardcoded-paths
200 (substitute* (find-files "tests" "\\.sh")
201 (("ping") "/run/setuid-programs/ping")))))))
210 iproute ; iproute, jq, nmap (ncat) and util-linux are for tests
215 (home-page "https://github.com/rootless-containers/slirp4netns")
216 (synopsis "User-mode networking for unprivileged network namespaces")
218 "slirp4netns provides user-mode networking (\"slirp\") for unprivileged
219 network namespaces.")
220 (license license:gpl2+)))
222 (define-public cni-plugins
230 (url "https://github.com/containernetworking/plugins")
231 (commit (string-append "v" version))))
233 (base32 "1j91in0mg4nblpdccyq63ncbnn2pc2zzjp1fh3jy0bsndllgv0nc"))
234 (file-name (git-file-name name version))))
235 (build-system go-build-system)
237 `(#:unpack-path "github.com/containernetworking/plugins"
238 #:tests? #f ; XXX: see stat /var/run below
239 #:phases (modify-phases %standard-phases
242 (with-directory-excursion
243 "src/github.com/containernetworking/plugins"
244 (invoke "./build_linux.sh"))))
246 (lambda* (#:key tests? #:allow-other-keys)
247 ; only pkg/ns tests run without root
249 (with-directory-excursion
250 "src/github.com/containernetworking/plugins/pkg/ns"
251 (invoke "stat" "/var/run") ; XXX: test tries to stat this directory
252 (invoke "unshare" "-rmn" "go" "test")))))
253 (add-before 'check 'set-test-environment
255 (setenv "XDG_RUNTIME_DIR" "/tmp/cni-rootless")))
257 (lambda* (#:key outputs #:allow-other-keys)
259 "src/github.com/containernetworking/plugins/bin"
260 (string-append (assoc-ref outputs "out") "/bin")))))))
263 (home-page "https://github.com/containernetworking/plugins")
264 (synopsis "Container Network Interface (CNI) network plugins")
266 "This package provides Container Network Interface (CNI) plugins to
267 configure network interfaces in Linux containers.")
268 (license license:asl2.0)))
270 ;; For podman to work, the user needs to run
271 ;; `sudo mount -t cgroup2 none /sys/fs/cgroup`
273 (define-public podman
281 (url "https://github.com/containers/podman")
282 (commit (string-append "v" version))))
284 (base32 "00wyjppd11hznmals9ax4s2qjklj6p1vfz4jjkp50bk8q4blxfbj"))
285 (file-name (git-file-name name version))))
287 (build-system gnu-build-system)
291 #~(list #$(string-append "CC=" (cc-for-target))
292 (string-append "PREFIX=" #$output))
293 #:tests? #f ; /sys/fs/cgroup not set up in guix sandbox
296 #~(modify-phases %standard-phases
298 (add-after 'unpack 'set-env
299 (lambda* (#:key inputs #:allow-other-keys)
300 ;; when running go, things fail because
301 ;; HOME=/homeless-shelter.
302 (setenv "HOME" "/tmp")))
304 (lambda* (#:key tests? #:allow-other-keys)
306 ;; (invoke "strace" "-f" "bin/podman" "version")
307 (invoke "make" "localsystem")
308 (invoke "make" "remotesystem"))))
309 (add-after 'unpack 'fix-hardcoded-paths
311 (substitute* (find-files "libpod" "\\.go")
312 (("exec.LookPath[(][\"]slirp4netns[\"][)]")
313 (string-append "exec.LookPath(\""
314 (which "slirp4netns") "\")")))
315 (substitute* "hack/install_catatonit.sh"
316 (("CATATONIT_PATH=\"[^\"]+\"")
317 (string-append "CATATONIT_PATH=" (which "true"))))
318 (substitute* "vendor/github.com/containers/common/pkg/config/config_linux.go"
319 (("/usr/local/libexec/podman")
320 (string-append #$output "/bin")))
321 (substitute* "vendor/github.com/containers/common/pkg/config/default.go"
322 (("/usr/libexec/podman/conmon") (which "conmon"))
323 (("/usr/local/libexec/cni")
324 (string-append #$(this-package-input "cni-plugins")
326 (("/usr/bin/crun") (which "crun"))))))))
333 go-github-com-go-md2man
345 (home-page "https://podman.io")
346 (synopsis "Manage containers, images, pods, and their volumes")
348 "Podman (the POD MANager) is a tool for managing containers and images,
349 volumes mounted into those containers, and pods made from groups of
351 (license license:asl2.0)))