;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2019 Leo Famulari
;;;
;;; This file is NOT part of GNU Guix, but is supposed to be used with GNU
;;; Guix and thus has the same license.
;;;
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix. If not, see .
(define-module (leo packages wireguard)
#:use-module (guix git-download)
#:use-module (guix licenses)
#:use-module (guix packages)
#:use-module (guix build utils)
#:use-module (guix utils) ;substitute-keyword-arguments
#:use-module (gnu packages linux))
(define %wireguard-version "0.0.20190123")
(define wireguard-source
(origin
;; XXX It's simpler to have a directory than a tarball?
(method git-fetch)
(uri (git-reference
(url "https://git.zx2c4.com/WireGuard")
(commit %wireguard-version)))
(file-name (string-append "wireguard-source-" %wireguard-version))
(sha256
(base32
"1lyl3nmsgp9jk9js3vz032vdx7cg9ynkwzdr19wrr26pkxhpcnxr"))))
(define-public linux-libre-with-wireguard
(package
(inherit linux-libre)
(name "linux-libre-with-wireguard")
(native-inputs
`(("wireguard-source" ,wireguard-source)
,@(package-native-inputs linux-libre)))
(arguments
(substitute-keyword-arguments (package-arguments linux-libre)
((#:phases phases)
`(modify-phases ,phases
(add-after 'unpack 'add-wireguard
(lambda* (#:key inputs outputs #:allow-other-keys)
(let* ((wireguard-src (assoc-ref inputs "wireguard-source"))
(wireguard-patch-tool (string-append wireguard-src "/contrib/kernel-tree/jury-rig.sh")))
(invoke "sh" wireguard-patch-tool "."))))))))))