From 7a0479bb7b8535acad2bf36c7a0b0498a1313422 Mon Sep 17 00:00:00 2001 From: Leo Famulari Date: Fri, 1 Mar 2019 19:30:51 -0500 Subject: [PATCH] gnu: Add WireGuard. * gnu/packages/vpn.scm (wireguard): New variable. --- gnu/packages/vpn.scm | 66 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/gnu/packages/vpn.scm b/gnu/packages/vpn.scm index e135fdef17..f15b111a92 100644 --- a/gnu/packages/vpn.scm +++ b/gnu/packages/vpn.scm @@ -8,6 +8,7 @@ ;;; Copyright © 2017 Julien Lepiller ;;; Copyright © 2018 Pierre Langlois ;;; Copyright © 2018 Meiyo Peng +;;; Copyright © 2019 Leo Famulari ;;; ;;; This file is part of GNU Guix. ;;; @@ -449,3 +450,68 @@ (define-public badvpn ;; 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. + ;; + (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)))