2016-07-13 22:15:11 +03:00
|
|
|
{ stdenv, fetchgit, libmnl, kernel ? null }:
|
2016-07-11 19:05:23 +03:00
|
|
|
|
2016-08-11 01:25:57 +03:00
|
|
|
# module requires Linux >= 4.1 https://www.wireguard.io/install/#kernel-requirements
|
|
|
|
assert kernel != null -> stdenv.lib.versionAtLeast kernel.version "4.1";
|
|
|
|
|
2016-07-13 22:15:11 +03:00
|
|
|
let
|
2016-07-31 14:57:37 +03:00
|
|
|
name = "wireguard-unstable-${version}";
|
2016-07-13 22:15:11 +03:00
|
|
|
|
2016-07-31 14:57:37 +03:00
|
|
|
version = "2016-07-22";
|
2016-07-11 19:05:23 +03:00
|
|
|
|
|
|
|
src = fetchgit {
|
|
|
|
url = "https://git.zx2c4.com/WireGuard";
|
2016-07-31 14:57:37 +03:00
|
|
|
rev = "8e8bf6f848c324603827c0e57f0856d5866ac32d";
|
|
|
|
sha256 = "11qrf9fxm6mkwjnjq7dgbisdric5w22cyfkqc6zx9fla2dz99mxk";
|
2016-07-11 19:05:23 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
meta = with stdenv.lib; {
|
|
|
|
homepage = https://www.wireguard.io/;
|
|
|
|
description = "Fast, modern, secure VPN tunnel";
|
|
|
|
license = licenses.gpl2;
|
|
|
|
platforms = platforms.linux;
|
|
|
|
};
|
2016-07-13 22:15:11 +03:00
|
|
|
|
|
|
|
module = stdenv.mkDerivation {
|
|
|
|
inherit src meta name;
|
|
|
|
|
|
|
|
preConfigure = ''
|
|
|
|
cd src
|
|
|
|
sed -i '/depmod/,+1d' Makefile
|
|
|
|
'';
|
|
|
|
|
|
|
|
KERNELDIR = "${kernel.dev}/lib/modules/${kernel.modDirVersion}/build";
|
|
|
|
INSTALL_MOD_PATH = "\${out}";
|
|
|
|
|
|
|
|
buildPhase = "make module";
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
tools = stdenv.mkDerivation {
|
|
|
|
inherit src meta name;
|
|
|
|
|
|
|
|
preConfigure = "cd src";
|
|
|
|
|
|
|
|
buildInputs = [ libmnl ];
|
|
|
|
|
|
|
|
makeFlags = [
|
|
|
|
"DESTDIR=$(out)"
|
|
|
|
"PREFIX=/"
|
|
|
|
"-C" "tools"
|
|
|
|
];
|
|
|
|
|
|
|
|
buildPhase = "make tools";
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
in if kernel == null
|
|
|
|
then tools
|
|
|
|
else module
|