summary refs log tree commit diff
path: root/pkgs/tools/networking/wireguard-tools/default.nix
blob: 8f983082a800e15e26e6adb96a7394f31a8d4b54 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
{ stdenv, lib, fetchurl, libmnl, useSystemd ? stdenv.isLinux }:

let
  inherit (lib) optional optionalString;
in

stdenv.mkDerivation rec {
  name = "wireguard-tools-${version}";
  version = "0.0.20180514";

  src = fetchurl {
    url    = "https://git.zx2c4.com/WireGuard/snapshot/WireGuard-${version}.tar.xz";
    sha256 = "1nk6yj1gdmpar99zzw39n1v795m6fxsrilg37d02jm780rgbd5g8";
  };

  preConfigure = "cd src";

  buildInputs = optional stdenv.isLinux libmnl;

  enableParallelBuilding = true;

  makeFlags = [
    "WITH_BASHCOMPLETION=yes"
    "WITH_WGQUICK=yes"
    "WITH_SYSTEMDUNITS=${if useSystemd then "yes" else "no"}"
    "DESTDIR=$(out)"
    "PREFIX=/"
    "-C" "tools"
  ];

  buildPhase = "make tools";

  postInstall = optionalString useSystemd ''
    substituteInPlace $out/lib/systemd/system/wg-quick@.service \
      --replace /usr/bin $out/bin
  '';

  meta = with stdenv.lib; {
    homepage     = https://www.wireguard.com/;
    downloadPage = https://git.zx2c4.com/WireGuard/refs/;
    description  = " Tools for the WireGuard secure network tunnel";
    maintainers  = with maintainers; [ ericsagnes mic92 zx2c4 ];
    license      = licenses.gpl2;
    platforms    = platforms.unix;
  };
}