diff mbox series

[bug#54335,09/14] gnu: Add go-github-com-vishvananda-netns.

Message ID 20220311031849.12681-9-dom@dominicm.dev
State New
Headers show
Series gnu: Add nebula. | expand

Commit Message

Dominic Martinez March 11, 2022, 3:18 a.m. UTC
* gnu/packages/golang.scm (go-github-com-vishvananda-netns): New variable.
---
 gnu/packages/golang.scm | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

Comments

M March 11, 2022, 7:47 a.m. UTC | #1
Dominic Martinez schreef op do 10-03-2022 om 22:18 [-0500]:
> +    (arguments '(#:tests? #f ; Tests require root privileges

Is this still the case?  Nowadays, some namespace stuff can be done
without root.

Greetings,
Maxime.
M March 11, 2022, 4:06 p.m. UTC | #2
Dominic Martinez schreef op do 10-03-2022 om 22:18 [-0500]:
> * gnu/packages/golang.scm (go-github-com-vishvananda-netns): New variable.

This is already packaged in Guix (go-netns).

Greetings,
Maxime.
Dominic Martinez March 11, 2022, 8:26 p.m. UTC | #3
Maxime Devos <maximedevos@telenet.be> writes:

> This is already packaged in Guix (go-netns).

This and netlink were my bad; thank you for pointing that out!
diff mbox series

Patch

diff --git a/gnu/packages/golang.scm b/gnu/packages/golang.scm
index a58b404079..bcf50439c7 100644
--- a/gnu/packages/golang.scm
+++ b/gnu/packages/golang.scm
@@ -9955,3 +9955,33 @@  (define-public go-github-com-songgao-water
 library for Go that efficiently works with standard packages like io, bufio,
 etc..  Use waterutil with it to work with TUN/TAP packets/frames.")
     (license license:bsd-3)))
+
+(define-public go-github-com-vishvananda-netns
+  (package
+    (name "go-github-com-vishvananda-netns")
+    (version "0.0.0-20211101163701-50045581ed74")
+    (source
+      (origin
+        (method git-fetch)
+        (uri (git-reference
+               (url "https://github.com/vishvananda/netns")
+               (commit (go-version->git-ref version))))
+        (file-name (git-file-name name version))
+        (sha256
+          (base32 "0kam780m036mk77fmc0w0z6qz4b5awkllcd1dps71zd1n82mr407"))))
+    (build-system go-build-system)
+    (arguments '(#:tests? #f ; Tests require root privileges
+                 #:import-path "github.com/vishvananda/netns"))
+    (native-inputs
+     (list go-golang-org-x-sys))
+    (home-page "https://github.com/vishvananda/netns")
+    (synopsis "Simple network namespace handling for Go")
+    (description
+      "Package netns allows ultra-simple network namespace handling.  NsHandles can be
+retrieved and set.  Note that the current namespace is thread local so actions
+that set and reset namespaces should use LockOSThread to make sure the namespace
+doesn't change due to a goroutine switch.  It is best to close NsHandles when
+you are done with them.  This can be accomplished via a `defer ns.Close()` on
+the handle.  Changing namespaces requires elevated privileges, so in most cases
+this code needs to be run as root.")
+    (license license:asl2.0)))