@@ -1,73 +1,36 @@
1−{ stdenv, fetchurl, libmnl, kernel ? null }:
1+{ stdenv, fetchzip, kernel, wireguard-tools }:
22
33# module requires Linux >= 3.10 https://www.wireguard.io/install/#kernel-requirements
4−assert kernel != null -> stdenv.lib.versionAtLeast kernel.version "3.10";
4+assert stdenv.lib.versionAtLeast kernel.version "3.10";
55
6−let
6+stdenv.mkDerivation rec {
77 name = "wireguard-${version}";
8−
98 version = "0.0.20180514";
109
11− src = fetchurl {
12− url = "https://git.zx2c4.com/WireGuard/snapshot/WireGuard-${version}.tar.xz";
13− sha256 = "1nk6yj1gdmpar99zzw39n1v795m6fxsrilg37d02jm780rgbd5g8";
14− };
10+ inherit (wireguard-tools) src;
1511
16− meta = with stdenv.lib; {
17− homepage = https://www.wireguard.com/;
18− downloadPage = https://git.zx2c4.com/WireGuard/refs/;
19− description = "A prerelease of an experimental VPN tunnel which is not to be depended upon for security";
20− maintainers = with maintainers; [ ericsagnes mic92 zx2c4 ];
21− license = licenses.gpl2;
22− platforms = platforms.linux;
23− };
24−
25− module = stdenv.mkDerivation {
26− inherit src meta name;
12+ preConfigure = ''
13+ cd src
14+ sed -i '/depmod/,+1d' Makefile
15+ '';
2716
28− preConfigure = ''
29− cd src
30− sed -i '/depmod/,+1d' Makefile
31− '';
17+ hardeningDisable = [ "pic" ];
3218
33− hardeningDisable = [ "pic" ];
19+ KERNELDIR = "${kernel.dev}/lib/modules/${kernel.modDirVersion}/build";
20+ INSTALL_MOD_PATH = "\${out}";
3421
35− KERNELDIR = "${kernel.dev}/lib/modules/${kernel.modDirVersion}/build";
36− INSTALL_MOD_PATH = "\${out}";
22+ NIX_CFLAGS = ["-Wno-error=cpp"];
3723
38− NIX_CFLAGS = ["-Wno-error=cpp"];
39−
40− nativeBuildInputs = kernel.moduleBuildDependencies;
41−
42− buildPhase = "make module";
43− };
24+ nativeBuildInputs = kernel.moduleBuildDependencies;
4425
45− tools = stdenv.mkDerivation {
46− inherit src meta name;
26+ buildPhase = "make module";
4727
48− preConfigure = "cd src";
49−
50− buildInputs = [ libmnl ];
51−
52− enableParallelBuilding = true;
53−
54− makeFlags = [
55− "WITH_BASHCOMPLETION=yes"
56− "WITH_WGQUICK=yes"
57− "WITH_SYSTEMDUNITS=yes"
58− "DESTDIR=$(out)"
59− "PREFIX=/"
60− "-C" "tools"
61− ];
62−
63− buildPhase = "make tools";
64−
65− postInstall = ''
66− substituteInPlace $out/lib/systemd/system/wg-quick@.service \
67− --replace /usr/bin $out/bin
68− '';
28+ meta = with stdenv.lib; {
29+ homepage = https://www.wireguard.com/;
30+ downloadPage = https://git.zx2c4.com/WireGuard/refs/;
31+ description = " Tools for the WireGuard secure network tunnel";
32+ maintainers = with maintainers; [ ericsagnes mic92 zx2c4 ];
33+ license = licenses.gpl2;
34+ platforms = platforms.linux;
6935 };
70−
71−in if kernel == null
72− then tools
73− else module
36+}