gnu: Add WireGuard.

* gnu/packages/vpn.scm (wireguard): New variable.
master
Leo Famulari 2019-03-01 19:30:51 -05:00
parent 4fdd4d3312
commit 7a0479bb7b
No known key found for this signature in database
GPG Key ID: 2646FA30BACA7F08
1 changed files with 66 additions and 0 deletions

View File

@ -8,6 +8,7 @@
;;; Copyright © 2017 Julien Lepiller <julien@lepiller.eu>
;;; Copyright © 2018 Pierre Langlois <pierre.langlois@gmx.com>
;;; Copyright © 2018 Meiyo Peng <meiyo.peng@gmail.com>
;;; Copyright © 2019 Leo Famulari <leo@famulari.name>
;;;
;;; This file is part of GNU Guix.
;;;
@ -449,3 +450,68 @@ The peer-to-peer VPN implements a Layer 2 (Ethernet) network between the peers
;; This project contains a bundled lwIP. lwIP is also released under the
;; 3-clause BSD license.
(license license:bsd-3)))
(define-public wireguard
(package
(name "wireguard")
(version "0.0.20190123")
(source (origin
(method url-fetch)
(uri (string-append "https://git.zx2c4.com/WireGuard/snapshot/"
"WireGuard-" version ".tar.xz"))
(sha256
(base32
"16yzzy4i0z2zslmyr3kppkvkrxryzwdil6v270w9w5mg65v3rlgd"))))
(build-system gnu-build-system)
(outputs '("out" ; The WireGuard userspace tools
"kernel-patch")) ; A patch to build Linux with WireGuard support
(arguments
`(#:make-flags
(list "CC=gcc"
"WITH_BASHCOMPLETION=yes"
;; Build and install the helper script wg-quick(8).
"WITH_WGQUICK=yes"
(string-append "PREFIX=" (assoc-ref %outputs "out"))
(string-append "SYSCONFDIR=" (assoc-ref %outputs "out") "/etc"))
#:modules ((guix build gnu-build-system)
(guix build utils)
(ice-9 popen)
(ice-9 textual-ports))
#:phases
(modify-phases %standard-phases
;; There is no ./configure script.
(delete 'configure)
;; Until WireGuard is added to the upstream Linux kernel, it is
;; distributed as a kernel patch generated by this script.
(add-after 'patch-source-shebangs 'make-patch
(lambda* (#:key outputs #:allow-other-keys)
(let* ((output (string-append (assoc-ref outputs "kernel-patch")
"/wireguard.patch"))
(patch-builder "./contrib/kernel-tree/create-patch.sh")
(port (open-input-pipe patch-builder))
(str (get-string-all port)))
(close-pipe port)
(mkdir-p (dirname output))
(call-with-output-file output
(lambda (port)
(format port "~a" str))))
#t))
(add-after 'make-patch 'chdir
(lambda _
(chdir "src/tools")
#t))
;; Otherwise the 'install-license-file' phase installs nothing.
;; <https://bugs.gnu.org/34703>
(add-after 'install 'reset-cwd
(lambda _
(chdir "../..")
#t)))))
(inputs
`(("libmnl" ,libmnl)))
(home-page "https://www.wireguard.com/")
(synopsis "Tools for configuring WireGuard")
(description "This package provides the userspace tools for setting and
retrieving configuration of WireGuard network tunnel interfaces, and a patch
that can be applied to a Linux kernel source tree in order to build it with
WireGuard support.")
(license license:gpl2)))