@@ -1,11 +1,10 @@
1−{ stdenv, fetchurl, libmnl, kernel ? null }:
1+{ stdenv, fetchurl, kernel }:
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
1110 src = fetchurl {
@@ -13,61 +12,28 @@ let
1312 sha256 = "1nk6yj1gdmpar99zzw39n1v795m6fxsrilg37d02jm780rgbd5g8";
1413 };
1514
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;
27−
28− preConfigure = ''
29− cd src
30− sed -i '/depmod/,+1d' Makefile
31− '';
32−
33− hardeningDisable = [ "pic" ];
34−
35− KERNELDIR = "${kernel.dev}/lib/modules/${kernel.modDirVersion}/build";
36− INSTALL_MOD_PATH = "\${out}";
37−
38− NIX_CFLAGS = ["-Wno-error=cpp"];
39−
40− nativeBuildInputs = kernel.moduleBuildDependencies;
41−
42− buildPhase = "make module";
43− };
44−
45− tools = stdenv.mkDerivation {
46− inherit src meta name;
15+ preConfigure = ''
16+ cd src
17+ sed -i '/depmod/,+1d' Makefile
18+ '';
4719
48− preConfigure = "cd src";
20+ hardeningDisable = [ "pic" ];
4921
50− buildInputs = [ libmnl ];
22+ KERNELDIR = "${kernel.dev}/lib/modules/${kernel.modDirVersion}/build";
23+ INSTALL_MOD_PATH = "\${out}";
5124
52− enableParallelBuilding = true;
25+ NIX_CFLAGS = ["-Wno-error=cpp"];
5326
54− makeFlags = [
55− "WITH_BASHCOMPLETION=yes"
56− "WITH_WGQUICK=yes"
57− "WITH_SYSTEMDUNITS=yes"
58− "DESTDIR=$(out)"
59− "PREFIX=/"
60− "-C" "tools"
61− ];
27+ nativeBuildInputs = kernel.moduleBuildDependencies;
6228
63− buildPhase = "make tools";
29+ buildPhase = "make module";
6430
65− postInstall = ''
66− substituteInPlace $out/lib/systemd/system/wg-quick@.service \
67− --replace /usr/bin $out/bin
68− '';
31+ meta = with stdenv.lib; {
32+ homepage = https://www.wireguard.com/;
33+ downloadPage = https://git.zx2c4.com/WireGuard/refs/;
34+ description = " Tools for the WireGuard secure network tunnel";
35+ maintainers = with maintainers; [ ericsagnes mic92 zx2c4 ];
36+ license = licenses.gpl2;
37+ platforms = platforms.linux;
6938 };
70−
71−in if kernel == null
72− then tools
73− else module
39+}