summary refs log tree commit diff
diff options
context:
space:
mode:
authorTimmy Douglas <mail@timmydouglas.com>2021-12-21 23:33:54 -0800
committerLudovic Courtès <ludo@gnu.org>2022-01-01 19:06:58 +0100
commit444b42f86b097aa5971a5df699afaa6a798fcafc (patch)
tree3363fa579261ef1515199d9813c6b7fdfa91e00d
parenta45e05a80fb83ea972d83dbce11de02985ce155c (diff)
downloadguix-444b42f86b097aa5971a5df699afaa6a798fcafc.tar.gz
gnu: Add cni-plugins.
* gnu/packages/containers.scm (cni-plugins): New variable.

Co-authored-by: Ludovic Courtès <ludo@gnu.org>
-rw-r--r--gnu/packages/containers.scm48
1 files changed, 48 insertions, 0 deletions
diff --git a/gnu/packages/containers.scm b/gnu/packages/containers.scm
index 63395a60a9..c5492a9c3b 100644
--- a/gnu/packages/containers.scm
+++ b/gnu/packages/containers.scm
@@ -212,3 +212,51 @@ containers or various tools.")
      "slirp4netns provides user-mode networking (\"slirp\") for unprivileged
 network namespaces.")
     (license license:gpl2+)))
+
+(define-public cni-plugins
+  (package
+    (name "cni-plugins")
+    (version "1.0.1")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/containernetworking/plugins")
+             (commit (string-append "v" version))))
+       (sha256
+        (base32 "1j91in0mg4nblpdccyq63ncbnn2pc2zzjp1fh3jy0bsndllgv0nc"))
+       (file-name (git-file-name name version))))
+    (build-system go-build-system)
+    (arguments
+     `(#:unpack-path "github.com/containernetworking/plugins"
+       #:tests? #f ; XXX: see stat /var/run below
+       #:phases (modify-phases %standard-phases
+                  (replace 'build
+                    (lambda _
+                      (with-directory-excursion
+                          "src/github.com/containernetworking/plugins"
+                        (invoke "./build_linux.sh"))))
+                  (replace 'check
+                    (lambda* (#:key tests? #:allow-other-keys)
+                      ; only pkg/ns tests run without root
+                      (when tests?
+                        (with-directory-excursion
+                            "src/github.com/containernetworking/plugins/pkg/ns"
+                          (invoke "stat" "/var/run") ; XXX: test tries to stat this directory
+                          (invoke "unshare" "-rmn" "go" "test")))))
+                  (add-before 'check 'set-test-environment
+                    (lambda _
+                      (setenv "XDG_RUNTIME_DIR" "/tmp/cni-rootless")))
+                  (replace 'install
+                    (lambda* (#:key outputs #:allow-other-keys)
+                      (copy-recursively
+                       "src/github.com/containernetworking/plugins/bin"
+                       (string-append (assoc-ref outputs "out") "/bin")))))))
+    (native-inputs
+     (list util-linux))
+    (home-page "https://github.com/containernetworking/plugins")
+    (synopsis "Container Network Interface (CNI) network plugins")
+    (description
+     "This package provides Container Network Interface (CNI) plugins to
+configure network interfaces in Linux containers.")
+    (license license:asl2.0)))